KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am currently running a windows service that creates multiple instances of a class. At the top of the service class and every other class in my solution, I have something like this: private static readonly ILog _log = LogManager.GetLogger(typeof(SomeClassTypeHere)); In my App.config, I have Log4Net configured for a single file: <log4net debug="true"> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="Logs\SomeLogFileName.xml" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <countDirection value="1" /> <maxSizeRollBackups value="30" /> <maximumFileSize value="10MB" /> <staticLogFileName value="true" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <layout type="log4net.Layout.XmlLayoutSchemaLog4j"> <locationInfo value="true" /> </layout> </appender> <root> <level value="INFO" /> <appender-ref ref="RollingFileAppender" /> </root> </log4net> This works great in most respects, and everything logs to a single file. However, I'd really like to create a separate log file for each instance of a particular class that my service creates. This is a class that we often need to monitor for support and we can have a handful of instances running at the same time. We don't know which instances will be running at a given time, so it makes creating static files in the configuration kinda painful. I tried taking off the readonly modifier and setting the following in the class constructor: _log = LogManager.GetLogger("DataCollectionClass_" + deviceName + "_" + DateTime.Now.ToString("MMddyyyy"), typeof(SomeClassTypeHere)); But that req
Tags (comma-separated)
Save Edits
Cancel