Is there a way to add the assembly version of assembly that is emiting the logging event?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think there is anything built-in that will do this, so you will probably need to create your own custom PatternConverter and PatternLayout (which is very easy)
The biggest problem is speed, since this will require log4net to generate the caller information and (in their own words)
If speed is not an issue, then something like this should work.
Apart from writing the GetAssemblyVersion method, that is all it takes to implement your own customer PatternConverter and PatternLayout.
You then have to change your log4net configuration file to tell it to use your custom routines.
eg if you have something like
you change it to something like
The GetAssemblyVersion method, could be something like the following
Note, it is not recommended to use assembly.GetName().Version as this can throw a SecurityException if the account has very local privileges.