Skip to content

Commit 8df9c71

Browse files
committed
added fileappender doc
1 parent fdef8a7 commit 8df9c71

File tree

5 files changed

+129
-1
lines changed

5 files changed

+129
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
**** xref:manual/configuration/coloredconsoleappender.adoc[]
2727
**** xref:manual/configuration/consoleappender.adoc[]
2828
**** xref:manual/configuration/eventlogappender.adoc[]
29+
**** xref:manual/configuration/fileappender.adoc[]
30+
**** xref:manual/configuration/rollingfileappender.adoc[]
2931
** xref:manual/examples.adoc[]
32+
** xref:manual/faq.adoc[]
3033
** xref:manual/filters.adoc[]
3134
** xref:manual/layouts.adoc[]
3235
* xref:features.adoc[]

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ These examples are by no means exhaustive configurations for the appenders.
2626
* xref:manual/configuration/bufferingforwardingappender.adoc[]
2727
* xref:manual/configuration/coloredconsoleappender.adoc[]
2828
* xref:manual/configuration/consoleappender.adoc[]
29-
* xref:manual/configuration/eventlogappender.adoc[]
29+
* xref:manual/configuration/eventlogappender.adoc[]
30+
* xref:manual/configuration/fileappender.adoc[]
31+
* xref:manual/configuration/rollingfileappender.adoc[]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
[#fileappender]
19+
= FileAppender
20+
21+
The following example shows how to configure the FileAppender to write messages to a file.
22+
The file specified is log-file.txt.
23+
The file will be appended to rather than overwritten each time the logging process starts.
24+
25+
[source,xml]
26+
----
27+
<appender name="FileAppender" type="log4net.Appender.FileAppender">
28+
<file value="log-file.txt" />
29+
<appendToFile value="true" />
30+
<layout type="log4net.Layout.PatternLayout">
31+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
32+
</layout>
33+
</appender>
34+
----
35+
36+
This example shows how to configure the file name to write to using an environment variable TEMP.
37+
The encoding to use to write to the file is also specified.
38+
39+
[source,xml]
40+
----
41+
<appender name="FileAppender" type="log4net.Appender.FileAppender">
42+
<file value="${TEMP}/log-file.txt" />
43+
<appendToFile value="true" />
44+
<encoding value="unicodeFFFE" />
45+
<layout type="log4net.Layout.PatternLayout">
46+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
47+
</layout>
48+
</appender>
49+
----
50+
51+
This example shows how to configure the appender to use the minimal locking model that allows multiple processes to write to the same file.
52+
53+
[source,xml]
54+
----
55+
<appender name="FileAppender" type="log4net.Appender.FileAppender">
56+
<file value="log-file.txt" />
57+
<appendToFile value="true" />
58+
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
59+
<layout type="log4net.Layout.PatternLayout">
60+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
61+
</layout>
62+
</appender>
63+
----
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
[#rollingfileappender]
19+
= RollingFileAppender
20+
21+
The following example shows how to configure the EventLogAppender to log to the Application event log on the local machine using the event Source of the AppDomain.FriendlyName.
22+
23+
[source,xml]
24+
----
25+
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
26+
<layout type="log4net.Layout.PatternLayout">
27+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
28+
</layout>
29+
</appender>
30+
----
31+
32+
This example shows how to configure the EventLogAppender to use a specific event Source.
33+
34+
[source,xml]
35+
----
36+
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
37+
<applicationName value="MyApp" />
38+
<layout type="log4net.Layout.PatternLayout">
39+
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
40+
</layout>
41+
</appender>
42+
----
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
[#faq]
18+
= Frequently Asked Questions

0 commit comments

Comments
 (0)