void IConfigureLogging.Configure(IConfigureThisEndpoint specifier)
        {
            var logToConsole = GetStdHandle(STD_OUTPUT_HANDLE) != IntPtr.Zero;

            if (Log4NetConfigurator.Log4NetExists)
            {
                SetLoggingLibrary.Log4Net(null, Log4NetAppenderFactory.CreateRollingFileAppender(null, "logfile"));

                if (logToConsole)
                {
                    SetLoggingLibrary.Log4Net(null, Log4NetAppenderFactory.CreateColoredConsoleAppender("Info"));
                }
            }
            else if (NLogConfigurator.NLogExists)
            {
                const string layout = "${longdate}|${level:uppercase=true}|${logger}|${message}${onexception:${newline}${exception:format=tostring}}";

                var targets = new List <object> {
                    NLogTargetFactory.CreateRollingFileTarget("logfile", layout)
                };

                if (logToConsole)
                {
                    targets.Add(NLogTargetFactory.CreateColoredConsoleTarget(layout));
                }

                SetLoggingLibrary.NLog(null, targets.ToArray());
            }
            else
            {
                ConfigureInternalLog4Net.Production(logToConsole);
            }
        }
Пример #2
0
 void IConfigureLogging.Configure(IConfigureThisEndpoint specifier)
 {
     if (Log4NetConfigurator.Log4NetExists)
     {
         SetLoggingLibrary.Log4Net(null, Log4NetAppenderFactory.CreateColoredConsoleAppender("Info"));
     }
     else if (NLogConfigurator.NLogExists)
     {
         SetLoggingLibrary.NLog(null, NLogTargetFactory.CreateColoredConsoleTarget());
     }
     else
     {
         ConfigureInternalLog4Net.Integration();
     }
 }