Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multiple log4net files.

Multiple log4net files.

Scheduled Pinned Locked Moved C#
helplearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Albu Marius
    wrote on last edited by
    #1

    I have a problem regarding multiple log files. In my project i have a GeneralLog (singleton instance) that is configured from the app.config of the application.

    		the file where to write the events<-->
    		
    		the lowest level a message must reach in order to get written in the log file<-->
    		
    		a value indicating that every message is appended to the log file<-->
    		
    		
    		
    		the message layout<-->
    

    This works. During the execution I create alot more (dynamically) log files from appenders defined like this:

            FileAppender generalLogAppender = new FileAppender();
            //Initialize the properties of the appender
            generalLogAppender.Name = generalLogFileName;
            generalLogAppender.File = "Log+"+ fileName + ".dat";
            generalLogAppender.AppendToFile = true;
            generalLogAppender.Threshold = Level.Warn;
            PatternLayout layout2 = new PatternLayout();
            layout2.ConversionPattern = "\[%d\] - %m%n";
            layout2.ActivateOptions();
            generalLogAppender.ActivateOptions();
            BasicConfigurator.Configure(generalLogAppender);
    

    The files are created, but nothing is written in them, only in the GeneralLog. I am really confused by this. I checked the net and of course CodeProject and found only static examples of logs, never a mixed case.

    I am fighting against the Universe... Reference-Rick Cook

    A 1 Reply Last reply
    0
    • A Albu Marius

      I have a problem regarding multiple log files. In my project i have a GeneralLog (singleton instance) that is configured from the app.config of the application.

      		the file where to write the events<-->
      		
      		the lowest level a message must reach in order to get written in the log file<-->
      		
      		a value indicating that every message is appended to the log file<-->
      		
      		
      		
      		the message layout<-->
      

      This works. During the execution I create alot more (dynamically) log files from appenders defined like this:

              FileAppender generalLogAppender = new FileAppender();
              //Initialize the properties of the appender
              generalLogAppender.Name = generalLogFileName;
              generalLogAppender.File = "Log+"+ fileName + ".dat";
              generalLogAppender.AppendToFile = true;
              generalLogAppender.Threshold = Level.Warn;
              PatternLayout layout2 = new PatternLayout();
              layout2.ConversionPattern = "\[%d\] - %m%n";
              layout2.ActivateOptions();
              generalLogAppender.ActivateOptions();
              BasicConfigurator.Configure(generalLogAppender);
      

      The files are created, but nothing is written in them, only in the GeneralLog. I am really confused by this. I checked the net and of course CodeProject and found only static examples of logs, never a mixed case.

      I am fighting against the Universe... Reference-Rick Cook

      A Offline
      A Offline
      Albu Marius
      wrote on last edited by
      #2

      Solved.

      BasicConfigurator.Configure(generalLogAppender);

      had to be called after the appender was attached to the logger.

      I am fighting against the Universe... Reference-Rick Cook

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups