开发者

log4net - why would the same MyLog.Debug line not work at one point of startup, but work at another point?

During startup of my WinForms application I'm noting that there are a couple of poi开发者_StackOverflownts (before the MainForm renders) that do a "MyDataSet.GetInstance()". For the first one the MyLog.Debug line comes through in the VS2008 output window, but for a later one it does work and come through.

What could explain this? What settings could I check at debug time to see why an output line for a MyLog.Debug line doesn't come out in the output window?

namespace IntranetSync
{
    public class MyDataSet
    {
        private static readonly ILog MyLog = LogManager.GetLogger(typeof(MyDataSet));

        public static MyDataSet GetInstance()
        {
            MyLog.Debug("MyDataSet GetInstance() =====================================");
            if (myDataSet == null)
            {
                myDataSet = new MyDataSet();
            }
            return myDataSet;
        }
.
.
.

PS. What I have been doing re log4net repository initialization is putting the following line as a private variables in the classes I use logging - is this OK?

    static class Program
    {
        private static readonly ILog MyLog = LogManager.GetLogger(typeof(MainForm));
.
.
.

    public class Coordinator
    {
        private static readonly ILog MyLog = LogManager.GetLogger(typeof(MainForm));
.
.
.

    public class MyDataSet
    {
        private static readonly ILog MyLog = LogManager.GetLogger(typeof(MyDataSet));
.
.
.


I'm guessing that the first call to the GetInstance method happens before the log4net repository is initialized. Du you explicitly initialize your repository, and if so: where?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜