Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
netcoreplus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
netcoreplus
Commits
02b7f3a3
Commit
02b7f3a3
authored
May 18, 2019
by
阿星Plus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log4Net
parent
707e93cb
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
517 additions
and
0 deletions
+517
-0
Log4NetLogger.cs
src/Plus.Log4Net/Log4NetLogger.cs
+410
-0
Log4NetLoggerFactory.cs
src/Plus.Log4Net/Log4NetLoggerFactory.cs
+70
-0
LoggingFacilityExtensions.cs
src/Plus.Log4Net/LoggingFacilityExtensions.cs
+15
-0
Plus.Log4Net.csproj
src/Plus.Log4Net/Plus.Log4Net.csproj
+9
-0
PlusCastleLog4NetModule.cs
src/Plus.Log4Net/PlusCastleLog4NetModule.cs
+13
-0
No files found.
src/Plus.Log4Net/Log4NetLogger.cs
0 → 100644
View file @
02b7f3a3
This diff is collapsed.
Click to expand it.
src/Plus.Log4Net/Log4NetLoggerFactory.cs
0 → 100644
View file @
02b7f3a3
using
Castle.Core.Logging
;
using
log4net
;
using
log4net.Config
;
using
log4net.Repository
;
using
System
;
using
System.IO
;
using
System.Xml
;
namespace
Plus.Log4Net
{
/// <summary>
/// Log4NetLoggerFactory
/// </summary>
public
class
Log4NetLoggerFactory
:
AbstractLoggerFactory
{
internal
const
string
DefaultConfigFileName
=
"log4net.config"
;
private
readonly
ILoggerRepository
_loggerRepository
;
public
Log4NetLoggerFactory
()
:
this
(
DefaultConfigFileName
)
{
}
public
Log4NetLoggerFactory
(
string
configFileName
)
{
_loggerRepository
=
LogManager
.
CreateRepository
(
typeof
(
Log4NetLoggerFactory
).
GetAssembly
(),
typeof
(
log4net
.
Repository
.
Hierarchy
.
Hierarchy
)
);
var
log4NetConfig
=
new
XmlDocument
();
log4NetConfig
.
Load
(
File
.
OpenRead
(
configFileName
));
XmlConfigurator
.
Configure
(
_loggerRepository
,
log4NetConfig
[
"log4net"
]);
}
public
Log4NetLoggerFactory
(
string
configFileName
,
bool
reloadOnChange
)
{
_loggerRepository
=
LogManager
.
CreateRepository
(
typeof
(
Log4NetLoggerFactory
).
GetAssembly
(),
typeof
(
log4net
.
Repository
.
Hierarchy
.
Hierarchy
)
);
if
(
reloadOnChange
)
{
XmlConfigurator
.
ConfigureAndWatch
(
_loggerRepository
,
new
FileInfo
(
configFileName
));
}
else
{
var
log4NetConfig
=
new
XmlDocument
();
log4NetConfig
.
Load
(
File
.
OpenRead
(
configFileName
));
XmlConfigurator
.
Configure
(
_loggerRepository
,
log4NetConfig
[
"log4net"
]);
}
}
public
override
ILogger
Create
(
string
name
)
{
if
(
name
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
name
));
}
return
new
Log4NetLogger
(
LogManager
.
GetLogger
(
_loggerRepository
.
Name
,
name
),
this
);
}
public
override
ILogger
Create
(
string
name
,
LoggerLevel
level
)
{
throw
new
NotSupportedException
(
"Logger levels cannot be set at runtime. Please review your configuration file."
);
}
}
}
\ No newline at end of file
src/Plus.Log4Net/LoggingFacilityExtensions.cs
0 → 100644
View file @
02b7f3a3
using
Castle.Facilities.Logging
;
namespace
Plus.Log4Net
{
/// <summary>
/// LoggingFacilityExtensions
/// </summary>
public
static
class
LoggingFacilityExtensions
{
public
static
LoggingFacility
UseLog4Net
(
this
LoggingFacility
loggingFacility
)
{
return
loggingFacility
.
LogUsing
<
Log4NetLoggerFactory
>();
}
}
}
\ No newline at end of file
src/Plus.Log4Net/Plus.Log4Net.csproj
View file @
02b7f3a3
...
...
@@ -4,4 +4,13 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Castle.LoggingFacility" Version="5.0.0" />
<PackageReference Include="log4net" Version="2.0.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plus\Plus.csproj" />
</ItemGroup>
</Project>
src/Plus.Log4Net/PlusCastleLog4NetModule.cs
0 → 100644
View file @
02b7f3a3
using
Plus.Modules
;
namespace
Plus.Log4Net
{
/// <summary>
/// Castle Log4Net module
/// </summary>
[
DependsOn
(
typeof
(
PlusLeadershipModule
))]
public
class
PlusCastleLog4NetModule
{
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment