1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Services
.Logging
.Log4netIntegration
18 using Castle
.Core
.Logging
;
20 using ILogger
=log4net
.Core
.ILogger
;
21 using Logger
= Castle
.Core
.Logging
.ILogger
;
22 using ExtendedLogger
= Castle
.Core
.Logging
.IExtendedLogger
;
24 public class ExtendedLog4netLogger
: Log4netLogger
, ExtendedLogger
26 private static readonly IContextProperties threadContextProperties
= new ThreadContextProperties();
27 private static readonly IContextProperties globalContextProperties
= new GlobalContextProperties();
28 private static readonly IContextStacks threadContextStacks
= new ThreadContextStacks();
30 private ExtendedLog4netFactory factory
;
32 public ExtendedLog4netLogger(ILog log
, ExtendedLog4netFactory factory
) : this(log
.Logger
, factory
)
36 public ExtendedLog4netLogger(ILogger logger
, ExtendedLog4netFactory factory
)
42 public override Logger
CreateChildLogger(String name
)
44 return CreateExtendedChildLogger(name
);
47 public ExtendedLogger
CreateExtendedChildLogger(string name
)
49 return Factory
.Create(Logger
.Name
+ "." + name
);
52 protected internal new ExtendedLog4netFactory Factory
54 get { return factory; }
55 set { factory = value; }
58 #region IExtendedLogger Members
61 /// Exposes the Global Context of the extended logger.
63 public IContextProperties GlobalProperties
65 get { return globalContextProperties; }
69 /// Exposes the Thread Context of the extended logger.
71 public IContextProperties ThreadProperties
73 get { return threadContextProperties; }
77 /// Exposes the Thread Stack of the extended logger.
79 public IContextStacks ThreadStacks
81 get { return threadContextStacks; }