LogService
LiangdunSdk LogService 提供了日志记录功能,使用的是log4net库来将日志记录到sqlite数据库中。
依赖
你需要导入LiangdunSdk.dll, 在Manifest.xml中依赖LiangdunSdk的bundle即可。
使用
internal static class MySDK
{
private static ILogService _logService;
private static Sdk _LiangdunSdk;
internal static ILogService LogService
{
get
{
if (_logService == null) _logService = LiangdunSdk.GetLogService();
return _logService;
}
}
internal static ILog CreateLogger(string name)
{
return LogService.CreateLog(Activator.Context.Bundle, name);
}
public static Sdk LiangdunSdk
{
get { return _LiangdunSdk; }
set { _LiangdunSdk = value; }
}
}
初始化MySDK的_LiangdunSdk后,即可使用服务!
在 public class Activator : IBundleActivator类的start方法中进行初始化:
Context = context;
var sdkFactoryService = context.GetFirstOrDefaultService<SdkFactoryService>();
MySDK.LiangdunSdk = sdkFactoryService.GetSdk(context);
static ILog logger = MySDK.CreateLogger("MySystem");
logger.Error(ex.Message);
logger.Info("info");
logger.Debug("debug info");
logger.Warn("warn info");
网友评论