Skip to content

Commit 4db619c

Browse files
committed
added RemoteSyslogAppender doc
1 parent a42aa09 commit 4db619c

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
**** xref:manual/configuration/managedcoloredconsoleappender.adoc[]
3333
**** xref:manual/configuration/memoryappender.adoc[]
3434
**** xref:manual/configuration/outputdebugstringappender.adoc[]
35+
**** xref:manual/configuration/remotesyslogappender.adoc[]
3536
**** xref:manual/configuration/smtpappender.adoc[]
37+
**** xref:manual/configuration/smtppickupdirappender.adoc[]
3638
**** xref:manual/configuration/traceappender.adoc[]
3739
**** xref:manual/configuration/udpappender.adoc[]
3840
** xref:manual/examples.adoc[]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ These examples are by no means exhaustive configurations for the appenders.
3333
* xref:manual/configuration/managedcoloredconsoleappender.adoc[]
3434
* xref:manual/configuration/memoryappender.adoc[]
3535
* xref:manual/configuration/outputdebugstringappender.adoc[]
36+
* xref:manual/configuration/remotesyslogappender.adoc[]
3637
* xref:manual/configuration/smtpappender.adoc[]
3738
* xref:manual/configuration/smtppickupdirappender.adoc[]
3839
* xref:manual/configuration/traceappender.adoc[]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
[#remotesyslogappender]
19+
= RemoteSyslogAppender
20+
21+
The following example shows how to configure the `RemoteSyslogAppender` to send log messages to a remote syslog daemon.
22+
The syslog server listens on UDP port 514 by default.
23+
24+
The following example sends all events with Level WARN or higher to the remote server 192.168.1.100 on the default port with UTF8-Encoding.
25+
26+
[source,xml]
27+
----
28+
<appender name="RemoteSyslogAppender" type="log4net.Appender.RemoteSyslogAppender">
29+
<encoding>UTF-8</encoding>
30+
<layout type="log4net.Layout.PatternLayout">
31+
<conversionPattern value="%date{MM/dd/yyyy HH:mm:ss.fff} [%thread] %-5level %logger - %message%newline" />
32+
</layout>
33+
<remoteAddress value="192.168.1.100" />
34+
<threshold value="WARN" />
35+
</appender>
36+
----
37+
38+
You can also specify:
39+
40+
* Facility (default: user)
41+
* Identity (default: application name)
42+
43+
[source,xml]
44+
----
45+
<appender name="RemoteSyslogAppender" type="log4net.Appender.RemoteSyslogAppender">
46+
<encoding>UTF-8</encoding>
47+
<facility>Alert</facility>
48+
<layout type="log4net.Layout.PatternLayout">
49+
<conversionPattern value="%date{MM/dd/yyyy HH:mm:ss.fff} [%thread] %-5level %logger - %message%newline" />
50+
</layout>
51+
<identity>MyApp-Canary</identity>
52+
<remoteAddress value="192.168.1.100" />
53+
<threshold value="WARN" />
54+
</appender>
55+
----
56+
57+
If your log message contains multiple lines, it will be logged as multiple separate syslog entries instead of a single multiline message.
58+
59+
This might lead to confusion when analyzing logs because related lines could appear interleaved with logs from other sources.
60+
61+
Example:
62+
63+
[source,csharp]
64+
----
65+
try
66+
{
67+
throw new InvalidTimeZoneException();
68+
}
69+
catch (InvalidTimeZoneException e)
70+
{
71+
logger.Error(e, "setting daylight saving time failed")
72+
}
73+
----
74+
75+
[source,log]
76+
----
77+
12/21/2024 14:07:41.508 [main] ERROR log4net.Tests - setting daylight saving time failed
78+
Exception of type 'System.InvalidTimeZoneException' was thrown.
79+
12/21/2024 14:07:41.511 [worker] WARN log4net.Tests - some unrelated log message
80+
at log4net.Tests.Appender.RemoteSyslogAppenderTest.LineBreakTest()
81+
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
82+
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
83+
----

0 commit comments

Comments
 (0)