You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by cristianmad <cr...@yahoo.com> on 2009/08/04 14:39:33 UTC
Log in more than 1 log destination for different assemblies.
Hi,
I am new to log4net and just starting reading some documentation about it.
We need to see if it would be a suitable logging solution for our
applications.
Our product (like most of them) uses a number of assemblies. I was wondering
if it would be possible for each assembly to log in its own log file (or any
other destination) even if they are loaded in the same application domain.
For example consider we have the following assemblies: A.dll and B.dll. Is
it possible for the two assemblies to log in their own log files even if
they are loaded in the same application domain?
If yes, could you please give me a very simple example?
Thank you,
Cristian
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p24807634.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Log in more than 1 log destination for different assemblies.
Posted by mattyboy <ma...@spdprintsolutions.com>.
Thanks, I'll have a look at that.
Michael Schall wrote:
>
> Instead of using the GlobalContext.Properties to define where your
> logs are coming from I would define a Shared/Static logger per class
> based on the fully qualified class name allowing you to use the
> logger hierarchy as defined here
> http://logging.apache.org/log4net/release/manual/introduction.html
>
> The FAQ has a section too...
> http://logging.apache.org/log4net/release/faq.html#Implementing%20Logging
>
> This way you can turn off specific loggers, direct them to different
> appenders, ...
>
> Mike
>
> On Wed, Sep 2, 2009 at 9:01 AM, mattyboy<ma...@spdprintsolutions.com>
> wrote:
>>
>> Thanks for the replying.
>>
>> When I say mutliple assemblies I have a GUI app. and it uses log4net to
>> log
>> to a file let's say 'C:\Claymore.log'.
>>
>> I have developed several .dll files which I call from within the GUI app.
>> I
>> want the code within the .dll files to also log to 'C:\Calymore.log'.
>>
>> I've actually just managed to get it working but I'm not using locking
>> and
>> wonder whether I should be or not for this scenario. As far as I'm aware
>> everything will run in the same process and should be fine without
>> locking......?
>>
>> Here's what I've done:
>>
>> In both the GUI front-end and each .dll I have added the following entry
>> to
>> the AssemblyInfo.vb (yes, I'm using vb.net!) file
>>
>> <Assembly:
>> log4net.Config.XMLConfigurator(ConfigFile:="Claymore.exe.log4net",
>> Watch:=True)>
>>
>> In GUI Front-End Assembly ONLY I've added 'Claymore.exe.log4net' file.
>>
>> Then in GUI Front-End class:
>>
>> Public Class frmDashboard
>> Public Shared logger As log4net.ILog
>>
>> Private Sub frmDashboard_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>> log4net.GlobalContext.Properties("AssemblyName") =
>> Assembly.GetExecutingAssembly.GetName.Name()
>> logger = log4net.LogManager.GetLogger("ClaymoreLogger")
>> logger.Info("Dashboard_Load() - Start")
>> logger.Debug("Dashboard_Load() - Finish")
>> Dim clsGUI As New ClaymoreGUI.clsDashboard()
>> End Sub
>> End Class
>>
>> In my ClaymoreGUI.dll:
>>
>> Public Class clsDashboard
>> Public Shared logger As log4net.ILog
>>
>> Public Sub New()
>> log4net.GlobalContext.Properties("AssemblyName") =
>> Assembly.GetExecutingAssembly.GetName.Name()
>> logger = log4net.LogManager.GetLogger("ClaymoreLogger")
>> logger.Info("New() - Start")
>> logger.Debug("New() - Finish")
>> End Sub
>> End Class
>>
>> Seems to work well :-)
>>
>>
>>
>> Michael Schall wrote:
>>>
>>> When you say multiple assemblies, I assume you mean multiple
>>> processes? Logging this way is not suggested as for each log message
>>> you have to reopen the file. If you have really light logging, it
>>> would probably be ok...
>>>
>>> Look at the LockingModel:
>>> http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.LockingModel.html
>>>
>>> From http://logging.apache.org/log4net/release/config-examples.html:
>>>
>>> This example shows how to configure the appender to use the minimal
>>> locking model that allows multiple processes to write to the same
>>> file.
>>>
>>> <appender name="FileAppender" type="log4net.Appender.FileAppender">
>>> <file value="${TMP}\log-file.txt" />
>>> <appendToFile value="true" />
>>> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>>> <layout type="log4net.Layout.PatternLayout">
>>> <conversionPattern value="%date [%thread] %-5level %logger
>>> [%property{NDC}] - %message%newline" />
>>> </layout>
>>> </appender>
>>>
>>> On Wed, Sep 2, 2009 at 3:28 AM, mattyboy<ma...@spdprintsolutions.com>
>>> wrote:
>>>>
>>>> Hi Christian,
>>>>
>>>> I'm actually looking to achieve the opposite, I want to know if it's
>>>> possible to get several assemblies to log to the SAME log file. Have
>>>> you
>>>> managed to achieve this? If so, do you have any example code/configs
>>>> etc.?
>>>>
>>>> Many Thanks
>>>>
>>>>
>>>> cristianmad wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am new to log4net and just starting reading some documentation about
>>>>> it.
>>>>> We need to see if it would be a suitable logging solution for our
>>>>> applications.
>>>>> Our product (like most of them) uses a number of assemblies. I was
>>>>> wondering if it would be possible for each assembly to log in its own
>>>>> log
>>>>> file (or any other destination) even if they are loaded in the same
>>>>> application domain.
>>>>> For example consider we have the following assemblies: A.dll and
>>>>> B.dll.
>>>>> Is
>>>>> it possible for the two assemblies to log in their own log files even
>>>>> if
>>>>> they are loaded in the same application domain?
>>>>> If yes, could you please give me a very simple example?
>>>>>
>>>>>
>>>>> Thank you,
>>>>> Cristian
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
>>>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>> :-):-):-)
>> --
>> View this message in context:
>> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25258147.html
>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25259963.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Log in more than 1 log destination for different assemblies.
Posted by Michael Schall <mi...@gmail.com>.
Instead of using the GlobalContext.Properties to define where your
logs are coming from I would define a Shared/Static logger per class
based on the fully qualified class name allowing you to use the
logger hierarchy as defined here
http://logging.apache.org/log4net/release/manual/introduction.html
The FAQ has a section too...
http://logging.apache.org/log4net/release/faq.html#Implementing%20Logging
This way you can turn off specific loggers, direct them to different
appenders, ...
Mike
On Wed, Sep 2, 2009 at 9:01 AM, mattyboy<ma...@spdprintsolutions.com> wrote:
>
> Thanks for the replying.
>
> When I say mutliple assemblies I have a GUI app. and it uses log4net to log
> to a file let's say 'C:\Claymore.log'.
>
> I have developed several .dll files which I call from within the GUI app. I
> want the code within the .dll files to also log to 'C:\Calymore.log'.
>
> I've actually just managed to get it working but I'm not using locking and
> wonder whether I should be or not for this scenario. As far as I'm aware
> everything will run in the same process and should be fine without
> locking......?
>
> Here's what I've done:
>
> In both the GUI front-end and each .dll I have added the following entry to
> the AssemblyInfo.vb (yes, I'm using vb.net!) file
>
> <Assembly:
> log4net.Config.XMLConfigurator(ConfigFile:="Claymore.exe.log4net",
> Watch:=True)>
>
> In GUI Front-End Assembly ONLY I've added 'Claymore.exe.log4net' file.
>
> Then in GUI Front-End class:
>
> Public Class frmDashboard
> Public Shared logger As log4net.ILog
>
> Private Sub frmDashboard_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> log4net.GlobalContext.Properties("AssemblyName") =
> Assembly.GetExecutingAssembly.GetName.Name()
> logger = log4net.LogManager.GetLogger("ClaymoreLogger")
> logger.Info("Dashboard_Load() - Start")
> logger.Debug("Dashboard_Load() - Finish")
> Dim clsGUI As New ClaymoreGUI.clsDashboard()
> End Sub
> End Class
>
> In my ClaymoreGUI.dll:
>
> Public Class clsDashboard
> Public Shared logger As log4net.ILog
>
> Public Sub New()
> log4net.GlobalContext.Properties("AssemblyName") =
> Assembly.GetExecutingAssembly.GetName.Name()
> logger = log4net.LogManager.GetLogger("ClaymoreLogger")
> logger.Info("New() - Start")
> logger.Debug("New() - Finish")
> End Sub
> End Class
>
> Seems to work well :-)
>
>
>
> Michael Schall wrote:
>>
>> When you say multiple assemblies, I assume you mean multiple
>> processes? Logging this way is not suggested as for each log message
>> you have to reopen the file. If you have really light logging, it
>> would probably be ok...
>>
>> Look at the LockingModel:
>> http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.LockingModel.html
>>
>> From http://logging.apache.org/log4net/release/config-examples.html:
>>
>> This example shows how to configure the appender to use the minimal
>> locking model that allows multiple processes to write to the same
>> file.
>>
>> <appender name="FileAppender" type="log4net.Appender.FileAppender">
>> <file value="${TMP}\log-file.txt" />
>> <appendToFile value="true" />
>> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>> <layout type="log4net.Layout.PatternLayout">
>> <conversionPattern value="%date [%thread] %-5level %logger
>> [%property{NDC}] - %message%newline" />
>> </layout>
>> </appender>
>>
>> On Wed, Sep 2, 2009 at 3:28 AM, mattyboy<ma...@spdprintsolutions.com>
>> wrote:
>>>
>>> Hi Christian,
>>>
>>> I'm actually looking to achieve the opposite, I want to know if it's
>>> possible to get several assemblies to log to the SAME log file. Have you
>>> managed to achieve this? If so, do you have any example code/configs
>>> etc.?
>>>
>>> Many Thanks
>>>
>>>
>>> cristianmad wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am new to log4net and just starting reading some documentation about
>>>> it.
>>>> We need to see if it would be a suitable logging solution for our
>>>> applications.
>>>> Our product (like most of them) uses a number of assemblies. I was
>>>> wondering if it would be possible for each assembly to log in its own
>>>> log
>>>> file (or any other destination) even if they are loaded in the same
>>>> application domain.
>>>> For example consider we have the following assemblies: A.dll and B.dll.
>>>> Is
>>>> it possible for the two assemblies to log in their own log files even if
>>>> they are loaded in the same application domain?
>>>> If yes, could you please give me a very simple example?
>>>>
>>>>
>>>> Thank you,
>>>> Cristian
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
>>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
> :-):-):-)
> --
> View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25258147.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
Re: Log in more than 1 log destination for different assemblies.
Posted by mattyboy <ma...@spdprintsolutions.com>.
Thanks for the replying.
When I say mutliple assemblies I have a GUI app. and it uses log4net to log
to a file let's say 'C:\Claymore.log'.
I have developed several .dll files which I call from within the GUI app. I
want the code within the .dll files to also log to 'C:\Calymore.log'.
I've actually just managed to get it working but I'm not using locking and
wonder whether I should be or not for this scenario. As far as I'm aware
everything will run in the same process and should be fine without
locking......?
Here's what I've done:
In both the GUI front-end and each .dll I have added the following entry to
the AssemblyInfo.vb (yes, I'm using vb.net!) file
<Assembly:
log4net.Config.XMLConfigurator(ConfigFile:="Claymore.exe.log4net",
Watch:=True)>
In GUI Front-End Assembly ONLY I've added 'Claymore.exe.log4net' file.
Then in GUI Front-End class:
Public Class frmDashboard
Public Shared logger As log4net.ILog
Private Sub frmDashboard_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
log4net.GlobalContext.Properties("AssemblyName") =
Assembly.GetExecutingAssembly.GetName.Name()
logger = log4net.LogManager.GetLogger("ClaymoreLogger")
logger.Info("Dashboard_Load() - Start")
logger.Debug("Dashboard_Load() - Finish")
Dim clsGUI As New ClaymoreGUI.clsDashboard()
End Sub
End Class
In my ClaymoreGUI.dll:
Public Class clsDashboard
Public Shared logger As log4net.ILog
Public Sub New()
log4net.GlobalContext.Properties("AssemblyName") =
Assembly.GetExecutingAssembly.GetName.Name()
logger = log4net.LogManager.GetLogger("ClaymoreLogger")
logger.Info("New() - Start")
logger.Debug("New() - Finish")
End Sub
End Class
Seems to work well :-)
Michael Schall wrote:
>
> When you say multiple assemblies, I assume you mean multiple
> processes? Logging this way is not suggested as for each log message
> you have to reopen the file. If you have really light logging, it
> would probably be ok...
>
> Look at the LockingModel:
> http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.LockingModel.html
>
> From http://logging.apache.org/log4net/release/config-examples.html:
>
> This example shows how to configure the appender to use the minimal
> locking model that allows multiple processes to write to the same
> file.
>
> <appender name="FileAppender" type="log4net.Appender.FileAppender">
> <file value="${TMP}\log-file.txt" />
> <appendToFile value="true" />
> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
> </layout>
> </appender>
>
> On Wed, Sep 2, 2009 at 3:28 AM, mattyboy<ma...@spdprintsolutions.com>
> wrote:
>>
>> Hi Christian,
>>
>> I'm actually looking to achieve the opposite, I want to know if it's
>> possible to get several assemblies to log to the SAME log file. Have you
>> managed to achieve this? If so, do you have any example code/configs
>> etc.?
>>
>> Many Thanks
>>
>>
>> cristianmad wrote:
>>>
>>> Hi,
>>>
>>> I am new to log4net and just starting reading some documentation about
>>> it.
>>> We need to see if it would be a suitable logging solution for our
>>> applications.
>>> Our product (like most of them) uses a number of assemblies. I was
>>> wondering if it would be possible for each assembly to log in its own
>>> log
>>> file (or any other destination) even if they are loaded in the same
>>> application domain.
>>> For example consider we have the following assemblies: A.dll and B.dll.
>>> Is
>>> it possible for the two assemblies to log in their own log files even if
>>> they are loaded in the same application domain?
>>> If yes, could you please give me a very simple example?
>>>
>>>
>>> Thank you,
>>> Cristian
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>
>>
>
>
:-):-):-)
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25258147.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Log in more than 1 log destination for different assemblies.
Posted by Michael Schall <mi...@gmail.com>.
When you say multiple assemblies, I assume you mean multiple
processes? Logging this way is not suggested as for each log message
you have to reopen the file. If you have really light logging, it
would probably be ok...
Look at the LockingModel:
http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppender.LockingModel.html
>From http://logging.apache.org/log4net/release/config-examples.html:
This example shows how to configure the appender to use the minimal
locking model that allows multiple processes to write to the same
file.
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="${TMP}\log-file.txt" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
</layout>
</appender>
On Wed, Sep 2, 2009 at 3:28 AM, mattyboy<ma...@spdprintsolutions.com> wrote:
>
> Hi Christian,
>
> I'm actually looking to achieve the opposite, I want to know if it's
> possible to get several assemblies to log to the SAME log file. Have you
> managed to achieve this? If so, do you have any example code/configs etc.?
>
> Many Thanks
>
>
> cristianmad wrote:
>>
>> Hi,
>>
>> I am new to log4net and just starting reading some documentation about it.
>> We need to see if it would be a suitable logging solution for our
>> applications.
>> Our product (like most of them) uses a number of assemblies. I was
>> wondering if it would be possible for each assembly to log in its own log
>> file (or any other destination) even if they are loaded in the same
>> application domain.
>> For example consider we have the following assemblies: A.dll and B.dll. Is
>> it possible for the two assemblies to log in their own log files even if
>> they are loaded in the same application domain?
>> If yes, could you please give me a very simple example?
>>
>>
>> Thank you,
>> Cristian
>>
>
> --
> View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
Re: Log in more than 1 log destination for different assemblies.
Posted by Ross Hinkley <ro...@gmail.com>.
It's possible, sure. If you're talking about having separate executables
log to the same logfile, in their application configurations, use the same
filename and path.
One thing I can't recall off the top of my head, though, is how log4net
deals with file locks. Someone out there, please correct me if I'm wrong,
but if you log two messages to the same file at nearly the same time, won't
they be buffered? (If memory serves, you can fiddle with the buffer size
using the "bufferSize" element.) I believe if you're using a FileAppender
you can specify what kind of locking you want to do, like:
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
That should prevent write lock exceptions.
Alternatively, I would humbly recommend you take a look at logging to a
database instead. It sounds like you want a central log, and you would gain
a little more flexibility that way.
-Ross
On Wed, Sep 2, 2009 at 3:28 AM, mattyboy <ma...@spdprintsolutions.com>wrote:
>
> Hi Christian,
>
> I'm actually looking to achieve the opposite, I want to know if it's
> possible to get several assemblies to log to the SAME log file. Have you
> managed to achieve this? If so, do you have any example code/configs etc.?
>
> Many Thanks
>
>
> cristianmad wrote:
> >
> > Hi,
> >
> > I am new to log4net and just starting reading some documentation about
> it.
> > We need to see if it would be a suitable logging solution for our
> > applications.
> > Our product (like most of them) uses a number of assemblies. I was
> > wondering if it would be possible for each assembly to log in its own log
> > file (or any other destination) even if they are loaded in the same
> > application domain.
> > For example consider we have the following assemblies: A.dll and B.dll.
> Is
> > it possible for the two assemblies to log in their own log files even if
> > they are loaded in the same application domain?
> > If yes, could you please give me a very simple example?
> >
> >
> > Thank you,
> > Cristian
> >
>
> --
> View this message in context:
> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
Re: Log in more than 1 log destination for different assemblies.
Posted by mattyboy <ma...@spdprintsolutions.com>.
Hi Christian,
I'm actually looking to achieve the opposite, I want to know if it's
possible to get several assemblies to log to the SAME log file. Have you
managed to achieve this? If so, do you have any example code/configs etc.?
Many Thanks
cristianmad wrote:
>
> Hi,
>
> I am new to log4net and just starting reading some documentation about it.
> We need to see if it would be a suitable logging solution for our
> applications.
> Our product (like most of them) uses a number of assemblies. I was
> wondering if it would be possible for each assembly to log in its own log
> file (or any other destination) even if they are loaded in the same
> application domain.
> For example consider we have the following assemblies: A.dll and B.dll. Is
> it possible for the two assemblies to log in their own log files even if
> they are loaded in the same application domain?
> If yes, could you please give me a very simple example?
>
>
> Thank you,
> Cristian
>
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p25253548.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
RE: Log in more than 1 log destination for different assemblies.
Posted by Florin Daneliuc <fl...@iquestint.com>.
Yes, in the application configuration file.
-----Original Message-----
From: cristianmad [mailto:cristianmad2000@yahoo.com]
Sent: Tuesday, August 04, 2009 4:24 PM
To: log4net-user@logging.apache.org
Subject: RE: Log in more than 1 log destination for different assemblies.
Thank you Florin for the fast response,
Just to confirm: The configration will be done in the application configuration file, right? Not, for example, in the A.dll.config and B.dll.config.
Florin Daneliuc-2 wrote:
>
>
> Yes it is very possible as long as this is properly configured.
> From each of the A and B assemblies you will need to use a different
> logger and this has to be properly configured.
>
> In assembly A you will use
> ....
> log4net.ILog logger = log4net.LogManager.GetLogger("<log name for
> assembly
> A>");
> ...
>
> and in config file you will have as
> <logger name="<log name for assembly A>">
> <appender-ref ref="AppenderForA" />
> </logger>
> where "Appender for A" will configured as described in
> http://logging.apache.org/log4net/release/config-examples.html
> The same for assembly B, just use "B" instead of "A".
>
> For more details I suggest you look into the documentation from
> http://logging.apache.org/log4net, though it might not be very
> straightforward.
>
> Best regards,
> florin
>
> -----Original Message-----
> From: cristianmad [mailto:cristianmad2000@yahoo.com]
> Sent: Tuesday, August 04, 2009 3:40 PM
> To: log4net-user@logging.apache.org
> Subject: Log in more than 1 log destination for different assemblies.
>
>
> Hi,
>
> I am new to log4net and just starting reading some documentation about it.
> We need to see if it would be a suitable logging solution for our
> applications.
> Our product (like most of them) uses a number of assemblies. I was
> wondering if it would be possible for each assembly to log in its own
> log file (or any other destination) even if they are loaded in the
> same application domain.
> For example consider we have the following assemblies: A.dll and
> B.dll. Is it possible for the two assemblies to log in their own log
> files even if they are loaded in the same application domain?
> If yes, could you please give me a very simple example?
>
>
> Thank you,
> Cristian
> --
> View this message in context:
> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different
> -assemblies.-tp24807634p24807634.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
>
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p24808629.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
RE: Log in more than 1 log destination for different assemblies.
Posted by cristianmad <cr...@yahoo.com>.
Thank you Florin for the fast response,
Just to confirm: The configration will be done in the application
configuration file, right? Not, for example, in the A.dll.config and
B.dll.config.
Florin Daneliuc-2 wrote:
>
>
> Yes it is very possible as long as this is properly configured.
> From each of the A and B assemblies you will need to use a different
> logger and this has to be properly configured.
>
> In assembly A you will use
> ....
> log4net.ILog logger = log4net.LogManager.GetLogger("<log name for assembly
> A>");
> ...
>
> and in config file you will have as
> <logger name="<log name for assembly A>">
> <appender-ref ref="AppenderForA" />
> </logger>
> where "Appender for A" will configured as described in
> http://logging.apache.org/log4net/release/config-examples.html
> The same for assembly B, just use "B" instead of "A".
>
> For more details I suggest you look into the documentation from
> http://logging.apache.org/log4net, though it might not be very
> straightforward.
>
> Best regards,
> florin
>
> -----Original Message-----
> From: cristianmad [mailto:cristianmad2000@yahoo.com]
> Sent: Tuesday, August 04, 2009 3:40 PM
> To: log4net-user@logging.apache.org
> Subject: Log in more than 1 log destination for different assemblies.
>
>
> Hi,
>
> I am new to log4net and just starting reading some documentation about it.
> We need to see if it would be a suitable logging solution for our
> applications.
> Our product (like most of them) uses a number of assemblies. I was
> wondering if it would be possible for each assembly to log in its own log
> file (or any other destination) even if they are loaded in the same
> application domain.
> For example consider we have the following assemblies: A.dll and B.dll. Is
> it possible for the two assemblies to log in their own log files even if
> they are loaded in the same application domain?
> If yes, could you please give me a very simple example?
>
>
> Thank you,
> Cristian
> --
> View this message in context:
> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p24807634.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>
>
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p24808629.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
RE: Log in more than 1 log destination for different assemblies.
Posted by Florin Daneliuc <fl...@iquestint.com>.
Yes it is very possible as long as this is properly configured.
>From each of the A and B assemblies you will need to use a different logger and this has to be properly configured.
In assembly A you will use
....
log4net.ILog logger = log4net.LogManager.GetLogger("<log name for assembly A>");
...
and in config file you will have as
<logger name="<log name for assembly A>">
<appender-ref ref="AppenderForA" />
</logger>
where "Appender for A" will configured as described in http://logging.apache.org/log4net/release/config-examples.html
The same for assembly B, just use "B" instead of "A".
For more details I suggest you look into the documentation from http://logging.apache.org/log4net, though it might not be very straightforward.
Best regards,
florin
-----Original Message-----
From: cristianmad [mailto:cristianmad2000@yahoo.com]
Sent: Tuesday, August 04, 2009 3:40 PM
To: log4net-user@logging.apache.org
Subject: Log in more than 1 log destination for different assemblies.
Hi,
I am new to log4net and just starting reading some documentation about it.
We need to see if it would be a suitable logging solution for our applications.
Our product (like most of them) uses a number of assemblies. I was wondering if it would be possible for each assembly to log in its own log file (or any other destination) even if they are loaded in the same application domain.
For example consider we have the following assemblies: A.dll and B.dll. Is it possible for the two assemblies to log in their own log files even if they are loaded in the same application domain?
If yes, could you please give me a very simple example?
Thank you,
Cristian
--
View this message in context: http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-assemblies.-tp24807634p24807634.html
Sent from the Log4net - Users mailing list archive at Nabble.com.