diff --git a/Assets/LoggerInit.cs b/Assets/LoggerInit.cs deleted file mode 100644 index cc0588d..0000000 --- a/Assets/LoggerInit.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class LoggerInit : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - OpenMetaverse.Logger.Log("First log. Logger.Log is working.", OpenMetaverse.Helpers.LogLevel.Info); - - } -} - diff --git a/Assets/LoggerInit.cs.meta b/Assets/LoggerInit.cs.meta deleted file mode 100644 index ea6956e..0000000 --- a/Assets/LoggerInit.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4295b92364fee74419e76675960a0886 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/LoggingConfiguration.cs b/Assets/LoggingConfiguration.cs deleted file mode 100644 index f2dbc25..0000000 --- a/Assets/LoggingConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -//using System.IO; -//using log4net.Config; -//using UnityEngine; - -//public static class LoggingConfiguration -//{ -// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] -// private static void ConfigureLogging() -// { -// XmlConfigurator.Configure(new FileInfo($"{Application.dataPath}/log4net.xml")); -// Debug.Log("xmlconfigurator called."); - - -// OpenMetaverse.Logger.Log("It is working!", OpenMetaverse.Helpers.LogLevel.Debug); -// } -//} \ No newline at end of file diff --git a/Assets/LoggingConfiguration.cs.meta b/Assets/LoggingConfiguration.cs.meta deleted file mode 100644 index 39db450..0000000 --- a/Assets/LoggingConfiguration.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f53b5470f9536d1429a05939e95ac2c5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/LibreMetaverse/Logger.cs b/Assets/Plugins/LibreMetaverse/Logger.cs index f8219cb..fcb4ceb 100644 --- a/Assets/Plugins/LibreMetaverse/Logger.cs +++ b/Assets/Plugins/LibreMetaverse/Logger.cs @@ -82,13 +82,12 @@ namespace OpenMetaverse //}; //BasicConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), appender); - //this is the new version, i hope it works. - var appender = new UnityDebugAppender(); - - appender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message"); + //1. log to unity console. + var unityDebugAppender = new UnityDebugAppender(); + unityDebugAppender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message"); //appender.Layout = new PatternLayout("%timestamp [%thread] %-5level - %message%newline"); - BasicConfigurator.Configure(appender); - + BasicConfigurator.Configure(unityDebugAppender); + if (Settings.LOG_LEVEL != Helpers.LogLevel.None) LogInstance.Warn("No log configuration found, defaulting to console logging"); diff --git a/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs b/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs new file mode 100644 index 0000000..19b221c --- /dev/null +++ b/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs @@ -0,0 +1,76 @@ +using System.IO; +using Disk; +using log4net; +using log4net.Appender; +using log4net.Layout; +using log4net.Repository.Hierarchy; +using Raindrop.Services.Bootstrap; +using UnityEngine; + +public static class LoggingConfiguration +{ + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] + private static void Configure() + { + // var key = "log4net.Internal.Debug"; + // string value = true.ToString(); + // + // try + // { + // var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + // var settings = configFile.AppSettings.Settings; + // if (settings[key] == null) + // { + // settings.Add(key, value); + // } + // else + // { + // settings[key].Value = value; + // } + // configFile.Save(ConfigurationSaveMode.Modified); + // ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name); + // } + // catch (ConfigurationErrorsException) + // { + // Debug.Log("Error writing app settings"); + // } + // + + Debug.Log("Application is configuring the global logger. \n" + + "We are using configuration file at: " + + $"{DirectoryHelpers.GetInternalCacheDir()}/log4net.xml"); + // var res = XmlConfigurator.Configure(new FileInfo($"{DirectoryHelpers.GetInternalCacheDir()}/log4net.xml")); + ConfigureLoggers( + Path.Combine(DirectoryHelpers.GetInternalCacheDir(), "log.txt")); + + + } + public static void ConfigureLoggers(string filepath) + { + // log4net.Config.XmlConfigurator.Configure(); + Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(); + + //1. log to unity console. + var unityDebugAppender = new UnityDebugAppender(); + unityDebugAppender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message"); + //appender.Layout = new PatternLayout("%timestamp [%thread] %-5level - %message%newline"); + // BasicConfigurator.Configure(unityDebugAppender); + hierarchy.Root.AddAppender(unityDebugAppender); + + + var logFileAppender = new RollingFileAppender(); + logFileAppender.Layout = new PatternLayout("%date{HH:mm:ss} [%level] - %message%newline"); + logFileAppender.File = filepath; + logFileAppender.AppendToFile = true; + logFileAppender.RollingStyle = RollingFileAppender.RollingMode.Size; + logFileAppender.MaxSizeRollBackups = 10; + logFileAppender.MaxFileSize = 250 * 1000; // 250KB + logFileAppender.StaticLogFileName = true; + logFileAppender.ActivateOptions(); + // XmlConfigurator.Configure(); + hierarchy.Root.AddAppender(logFileAppender); + + hierarchy.Configured = true; + } + +} \ No newline at end of file diff --git a/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs.meta b/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs.meta new file mode 100644 index 0000000..ef6c522 --- /dev/null +++ b/Assets/Raindrop/Bootstrap/LoggingConfiguration.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c6878c9d86df41169b650f796c06e270 +timeCreated: 1546859428 \ No newline at end of file diff --git a/Assets/log4net.xml b/Assets/log4net.xml index 3716106..bec1340 100644 --- a/Assets/log4net.xml +++ b/Assets/log4net.xml @@ -1,12 +1,12 @@ + - - - - + + + + - - + + - - \ No newline at end of file + \ No newline at end of file diff --git a/Assets/log4net.xml.meta b/Assets/log4net.xml.meta index a02f13c..99c85a2 100644 --- a/Assets/log4net.xml.meta +++ b/Assets/log4net.xml.meta @@ -1,7 +1,3 @@ -fileFormatVersion: 2 -guid: e86452698ba1c0946826237d6247b4b7 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 3ad4e357e4824d6f95265a0fcecfce8f +timeCreated: 1546859523 \ No newline at end of file