Skip to content

Commit f90f3eb

Browse files
committed
added console appenders
1 parent 20e8e19 commit f90f3eb

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

src/site/antora/modules/ROOT/nav.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*** xref:manual/configuration/examples.adoc[]
2424
**** xref:manual/configuration/adonetappender.adoc[]
2525
**** xref:manual/configuration/bufferingforwardingappender.adoc[]
26+
**** xref:manual/configuration/coloredconsoleappender.adoc[]
27+
**** xref:manual/configuration/consoleappender.adoc[]
2628
** xref:manual/examples.adoc[]
2729
** xref:manual/filters.adoc[]
2830
** xref:manual/layouts.adoc[]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
////
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
////
17+
18+
[#coloredconsoleappender]
19+
= ColoredConsoleAppender
20+
21+
The following example shows how to configure the ColoredConsoleAppender to log messages to the console.
22+
By default the messages are sent to the console standard output stream.
23+
This example shows how to highlight error messages.
24+
25+
[source,xml]
26+
----
27+
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
28+
<mapping>
29+
<level value="ERROR" />
30+
<foreColor value="Red, HighIntensity"/>
31+
</mapping>
32+
<layout type="log4net.Layout.PatternLayout">
33+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
34+
</layout>
35+
</appender>
36+
----
37+
38+
This example shows how to colorize multiple levels.
39+
40+
[source,xml]
41+
----
42+
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
43+
<mapping>
44+
<level value="ERROR" />
45+
<foreColor value="Red, HighIntensity"/>
46+
</mapping>
47+
<mapping>
48+
<level value="DEBUG" />
49+
<foreColor value="LightGray" />
50+
</mapping>
51+
<layout type="log4net.Layout.PatternLayout">
52+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
53+
</layout>
54+
</appender>
55+
----
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
////
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
////
17+
18+
[#consoleappender]
19+
= ConsoleAppender
20+
21+
The following example shows how to configure the ConsoleAppender to log messages to the console.
22+
By default the messages are sent to the console standard output stream.
23+
24+
[source,xml]
25+
----
26+
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
27+
<layout type="log4net.Layout.PatternLayout">
28+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
29+
</layout>
30+
</appender>
31+
----
32+
33+
This example shows how to direct the log messages to the console error stream.
34+
35+
[source,xml]
36+
----
37+
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
38+
<target value="Console.Error" />
39+
<layout type="log4net.Layout.PatternLayout">
40+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
41+
</layout>
42+
</appender>
43+
----

src/site/antora/modules/ROOT/pages/manual/configuration/examples.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ This document presents example configurations for the built-in appenders. These
2323
These examples are by no means exhaustive configurations for the appenders.
2424
2525
* xref:manual/configuration/adonetappender.adoc[]
26-
* xref:manual/configuration/bufferingforwardingappender.adoc[]
26+
* xref:manual/configuration/bufferingforwardingappender.adoc[]
27+
* xref:manual/configuration/coloredconsoleappender.adoc[]
28+
* xref:manual/configuration/consoleappender.adoc[]

0 commit comments

Comments
 (0)