How to setup the logging properly?

Hello!

I've set up a self-hosted photon server. I've added tutorial ChatServer application. And it all seems fine.
Then I've wanted to add the logging to a server code. I've used the tutorial again (as far as I understood it), so:
1. I've added ExitGames.Logging.Log4Net.dll and log4net.dll to the ChatServer project.
2. I've put log4net.config into the bin directory of the ChatServer
3. I've put the tutorial config to the log4net.config

4. I've added this code the ChatPeer.cs
using ExitGames.Logging;
using ExitGames.Logging.Log4Net;
...
private static readonly ILogger log = LogManager.GetCurrentClassLogger();
5. And I want to use the logger like this:
log.DebugFormat("{0}", "Some debug");
log.InfoFormat("{0}", "Or some info");

But there is nothing printed to any files and log.IsDebugEnabled(or any other level) returns false.
I'm sure I've missed something. Could you please explain to me how to configure the logging properly?

Thanks a lot!

Best Answer

  • MufanMufan
    Accepted Answer
    My bad! My problem was with the wrong LogManager setup. Now I see the logs and can configure them, give or take... So, that's enough for this moment for me.

    Btw, 'ALL' works. Moreover, I can delete all directives from the log4net.config. And it still prints logs (DEBUG and INFO). Now I'm wondering how I can really configure that to print 'debug' in one file and 'info' in another one. But that's another question.

Answers

  • Hi, @Mufan

    There is no 'ALL' log level. you should use either DEBUG or INFO or WARN or ERROR or FATAL

    best,
    ilya
  • Ok! I might have been confused by that. Because that is the example...
    Anyway, I've tried to change ALL to any of these levels and there are no changes((
  • MufanMufan
    Accepted Answer
    My bad! My problem was with the wrong LogManager setup. Now I see the logs and can configure them, give or take... So, that's enough for this moment for me.

    Btw, 'ALL' works. Moreover, I can delete all directives from the log4net.config. And it still prints logs (DEBUG and INFO). Now I'm wondering how I can really configure that to print 'debug' in one file and 'info' in another one. But that's another question.
  • thank you for info.

    you may find asnwer on your in web. just hint that every logger may have filters

    best,
    ilya
Sign In or Register to comment.