Per object flat file listener

Topics: Logging Application Block
Jan 20, 2011 at 9:27 AM

Hello!

I would like to create flat file listener for each instance of my class. Is it possible in EL5?

How can I implement this?

 

 

 

Jan 20, 2011 at 10:53 AM

Can you provide more details on what purposes or what specific scenario are you trying to achieve on this? Also, is what you meant by creating a flat file listener for each instance of your class is to be able to dynamically create the listener or setting up your logging configuration during runtime, right? If yes, try looking into utilizing the Fluent Configuration API which will provide you to be able to programmatically manipulate your Logging App Block configuration. HTH.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
 entlib.support@avanade.com


Jan 20, 2011 at 11:13 AM
AvanadeSupport wrote:

Can you provide more details on what purposes or what specific scenario are you trying to achieve on this? Also, is what you meant by creating a flat file listener for each instance of your class is to be able to dynamically create the listener or setting up your logging configuration during runtime, right? If yes, try looking into utilizing the Fluent Configuration API which will provide you to be able to programmatically manipulate your Logging App Block configuration. HTH.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
 entlib.support@avanade.com 



I would like to configure logging settings in app.config file. At run-time when new instance of some of my classes is created it should be logged in separate file (with name based on for example some object id). Many objects of my class can be instanciated during execution. Each of them should write logging messages in separate file. It would be great if all parameters of listening and formatting keep being in app.config.. So when new object is created parameters of some  listener and formatter should be copied from app.config to new instance of logger and formatter created at run-time.

 

Does Fluent Configuration API meet my needs?

How can I access from code app.config based configuration of logging app block?

Jan 20, 2011 at 8:32 PM

Enterprise Library logging doesn't support this scenario. I'm not sure there's any logging framework that does.

You could get the same effect with a little post-processing. Write everything to a single file, but have a well-defined title or category used to identify each instance. Then write a simple program that reads the log file and splits it out based on the title / category / whatever into separate files per instance.

 

Jan 21, 2011 at 7:01 AM
ctavares wrote:

Enterprise Library logging doesn't support this scenario. I'm not sure there's any logging framework that does.

You could get the same effect with a little post-processing. Write everything to a single file, but have a well-defined title or category used to identify each instance. Then write a simple program that reads the log file and splits it out based on the title / category / whatever into separate files per instance.

 

I have used this scenario in log4net.

It allows this through changing on the fly existing configuration in memory.