Log4net, how to log a verbose message?

前端 未结 6 857
醉酒成梦
醉酒成梦 2020-12-14 09:53

I can log info messages without a problem, but can\'t figure out how to log verbose messages. Any help would be welcomed.

My problem is:

loggingEvent.Level

6条回答
  •  误落风尘
    2020-12-14 10:34

    You cannot figure out, because, AFAIK there is no "verbose" level in log4net. Is there one in log4j?

    Following are the levels

    ALL DEBUG INFO WARN ERROR FATAL OFF

    Informational messages are the ones where you specify what you are doing currently in your application. Those messages spit out by OS commands or tools when you say -verbose, would be these kind of messages.

    Debug messages are mostly for programmers and they allow you to write information such as variable creation, life-cycle, exception stack traces etc. Something that only the programmer/ support staff would be interested in.

    [Edit] Just thought of this. You can very well add a switch or config element to your application named "verbose" and then spit out the informational messages if set to true. Or wrap the logging in a helper method, which will log in log4net as well as send the same message to console. Also, you can use the ConsoleAppender to log messages to console. I have never used it though. Is this what you were looking for?

    Hope this helps.

提交回复
热议问题