Why can't I get log4net working - please advice.

1,282 views
Skip to first unread message

item...@hotmail.com

unread,
May 5, 2014, 3:46:37 AM5/5/14
to particula...@googlegroups.com
Helpful information to include
Product name: NServiceBus
Version: 4.4.2
Stacktrace:
Description:

log4net version 1.2.10.

I host my own bus in a console application. I have the requirement, that the log4net configuration comes from a repository (not app.config). 
When I configure the bus, the log system is already running as it should. But after:

Configure.With()

I see this in my console:

log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository]
log4net: Logger: No appenders could be found for logger [NServiceBus.Configure]
repository [log4net-default-repository]
log4net: Logger: Please initialize the log4net system properly.

And after that, all logs are piped to Console only. 
I have tried all sorts of combinations of Configure.Instance.Log4Net(), SetLoggingLibrary but no matter what, log4net shutsdown when Configure.With() is called. 

Going crazy here - this code worked with 3.x :) Please advice.

-- 
Werner

Alexey Zimarev

unread,
May 5, 2014, 4:09:42 AM5/5/14
to particula...@googlegroups.com
I call SetLoggingLibrary.Log4Net(); before Configure.With() and it works fine.


--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
To view this discussion on the web visit https://groups.google.com/d/msgid/particularsoftware/0f646eb9-2c8d-4d83-9a14-0248c171925a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

item...@hotmail.com

unread,
May 5, 2014, 5:26:20 AM5/5/14
to particula...@googlegroups.com
Yes but it doesn't work here. The only way I can get it to work, is to reinitialize log4net after Configure.With().

Are you sure you have logging working before calling "SetLoggingLibrary.Log4Net()" ? Because, if I do not initialize log4net before any NSB code, it all works. The problem only shows when log4net is already running before starting any NSB coding...

-- 
Werner


Den mandag den 5. maj 2014 10.09.42 UTC+2 skrev Alexey Zimarev:
I call SetLoggingLibrary.Log4Net(); before Configure.With() and it works fine.
On Mon, May 5, 2014 at 9:46 AM, <item...@hotmail.com> wrote:
Helpful information to include
Product name: NServiceBus
Version: 4.4.2
Stacktrace:
Description:

log4net version 1.2.10.

I host my own bus in a console application. I have the requirement, that the log4net configuration comes from a repository (not app.config). 
When I configure the bus, the log system is already running as it should. But after:

Configure.With()

I see this in my console:

log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository]
log4net: Logger: No appenders could be found for logger [NServiceBus.Configure]
repository [log4net-default-repository]
log4net: Logger: Please initialize the log4net system properly.

And after that, all logs are piped to Console only. 
I have tried all sorts of combinations of Configure.Instance.Log4Net(), SetLoggingLibrary but no matter what, log4net shutsdown when Configure.With() is called. 

Going crazy here - this code worked with 3.x :) Please advice.

-- 
Werner

--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsub...@googlegroups.com.

item...@hotmail.com

unread,
May 5, 2014, 6:18:54 AM5/5/14
to particula...@googlegroups.com
I cannot replicate this outside our application so it must be an issue with my code. 
Thanks Alexey.

Ramon Smits

unread,
May 5, 2014, 7:56:20 AM5/5/14
to particula...@googlegroups.com

Maybe it helps to see what log4net is doing by letting log4net log its own code.

<configuration>
	<appSettings>
		<add key="log4net.Internal.Debug" value="true"/>
	</appSettings>
</configuration>


-- Ramon




-- Ramon


To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.

To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.

item...@hotmail.com

unread,
May 7, 2014, 9:44:51 AM5/7/14
to particula...@googlegroups.com
Hi Ramon,

Already been there, that setting gave me the "log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository]" sentence.
But I was not aware that it could be turned on by appsetting - very useful indeed as we pull log4net configuration from another source (other than app.config). 

Until now I configured like this:

<log4net debug="true">
...
</log4net>

Anyways, the log system shutdown because someone explicitly called log4net.LogManager.Shutdown(), obviously not the best idea :)

-- 
Werner

-- Ramon


-- 
Werner

To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsub...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
Reply all
Reply to author
Forward
0 new messages