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);
            }
        }
Ejemplo n.º 2
0
        static void SetupLogging(EndpointConfiguration endpointConfiguration)
        {
            var logDir = ".\\logfiles\\";

            Directory.CreateDirectory(logDir);

            var logFile = Path.Combine(logDir, endpointConfiguration.EndpointName + ".txt");

            if (File.Exists(logFile))
            {
                File.Delete(logFile);
            }

            var logLevel = "INFO";

            SetLoggingLibrary.Log4Net(null, Log4NetAppenderFactory.CreateRollingFileAppender(logLevel, logFile));
        }
Ejemplo n.º 3
0
        public void Can_create_RollingFileAppender()
        {
            var appender = Log4NetAppenderFactory.CreateRollingFileAppender("Debug", "logfile");

            Assert.IsNotNull(appender);
        }