日期:2014-05-18  浏览次数:20522 次

EnterpriseLibrary 2.0 LOG信息是乱码
try
                {
                        int   error   =   Convert.ToInt32( "d ");
                }
                catch   (Exception   ex)
                {
                        LogEntry   log   =   new   LogEntry();
                        //事件ID
                        log.EventId   =   2000;
                        //日志优先级
                        log.Priority   =   2;
                        log.Message   =   "嘿嘿 ";

                        //日志类别
                        ICollection <string>   coll   =   new   List <string> ();
                        //设置类别为DataBase,这就确定了你的日志是写入到数据库的
                        //因为DataBase这个类别中包含一个DataBase   Trace   Listener
                        coll.Add( "DataBase ");

                        log.Categories   =   coll;


                        //写入日志
                        Logger.Write(log);
                        //bool   rethrow   =   ExceptionPolicy.HandleException(ex,   "UI   Policy ");
                        //if   (rethrow)
                               
                }
log.Message是中文   在数据库里面就会乱码。怎么解决啊
我的日志就写在数据库里的

------解决方案--------------------
改成nvarchar类型的就可以了,否则就容易出现乱码