Closed YamilBracho closed 6 years ago
Hi, I would like to send my log message to GrayLog and using a common library for .NEt Framework and for .NetCore. Just for testing i am showing logging message to console. For .Net Framework works fine but for .NetCore i do not get any output.
My config file is
<?xml version="1.0" encoding="utf-8" ?> <log4net> <appender name="Console" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="app:%property{AppName},version:2.0,Environment:DEV,Level:%level: %message%newline" /> </layout> </appender> <logger name="GelfUdpAppenderNA"> <level value="ALL" /> <appender-ref ref="Console" /> </logger> </log4net>
And in my code i check if my app is a .NET Core or not .
FileInfo fi = new FileInfo("log4net.xml"); if (OSUtils.IsNetCoreFramework()) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, fi); } else { XmlConfigurator.Configure(fi); } ILog iLog = LogManager.GetLogger("GelfUdpAppenderNA"); switch (eventType) { case EventType.Debug: iLog.Debug(logMessage); break; case EventType.Information: iLog.Info(logMessage); break; case EventType.Error: iLog.Error(logMessage); break; }
Any hint for solve this ? TIA, Yamil
Hi,
You could try to copy the log4net.xml to the Output Directory
log4net.xml
Output Directory
yeah!!! I always forget that!!1
Thanks
:)
Hi, I would like to send my log message to GrayLog and using a common library for .NEt Framework and for .NetCore. Just for testing i am showing logging message to console. For .Net Framework works fine but for .NetCore i do not get any output.
My config file is
And in my code i check if my app is a .NET Core or not .
Any hint for solve this ? TIA, Yamil