You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by ozgurnevres <oz...@gmail.com> on 2018/02/12 14:55:27 UTC

Logging using Log4Net

Hi,

I want to use log4net for logging. Ignite starts from
ApplicationConfiguration like this:
Ignition.StartFromApplicationConfiguration()

It seems it isn't logging in C:\Logs. What am I doing wrong? Ignite
configuration is like 

  <igniteConfiguration
xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
gridName="myGrid1" clientMode="false" jvmMaxMemoryMb="6144">
    <logger type="Apache.Ignite.Log4Net.IgniteLog4NetLogger,
Apache.Ignite.Log4Net" />
...

And Log4Net configuration in app.config:
  <log4net>
    <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
      
      
      
      
      
      
      
      
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger
[%property{LogName}] - %message%newline" />
      </layout>
    </appender>
    <logger name="ProductionLogger">
      <appender-ref ref="RollingLogFileAppender" />
      
      <level value="ALL" />
    </logger>
  </log4net>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by Alexey Popov <ta...@gmail.com>.
Igg.zip <http://apache-ignite-users.70518.x6.nabble.com/file/t1428/Igg.zip>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by ozgurnevres <oz...@gmail.com>.
Great. Many thanks!



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by Alexey Popov <ta...@gmail.com>.
Hi,

Hm, actually, you've got several log4net misconfigurations in your solution.
Everything was fine with Ignite config itself ).
Please see updated minified solution attached. Just "build a solution" and
it will restore all required packages.

The following log4net misconfigurations fixed:

1. Your app.config file section <log4net> was ignored, an explicit call
XmlConfigurator.Configure() is required for log4net.

2. you should always have <root> logger in <log4net> section.

3. <logger> name attribute could not be abstract. It should have some
package name.

4. %property{LogName} from xml should be initialized in global context
before usage. Please see call 
log4net.GlobalContext.Properties["LogName"] =
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

Please find more info about log4net at [1]

Thank you,
Alexey

[1] https://logging.apache.org/log4net/release/manual/configuration.html




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by ozgurnevres <oz...@gmail.com>.
"please ensure that your log4net configuration section <log4net> is 
actually used"

How can I ensure that? It seems there's no property in logger configuration
to tell which appender will be used.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by ozgurnevres <oz...@gmail.com>.
You can download a simple reproducer project here: 
https://1drv.ms/u/s!ApZeEREhT0aVxHwU56ywJxhuVWvR
<https://1drv.ms/u/s!ApZeEREhT0aVxHwU56ywJxhuVWvR>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Logging using Log4Net

Posted by Alexey Popov <ta...@gmail.com>.
Hi,

There could be several issues. Unfortunately, you just provided some config
snippets.

First of all, please add <file value="somename.log" /> to your appender
RollingLogFileAppender config.

Then, please ensure that your log4net configuration section <log4net> is
actually used.
It is better to have a separate file log4net.config file.

Please share a simple reproducer project if you still face any issue.

Thank you,
Alexey



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/