aboutsummaryrefslogtreecommitdiffstats
path: root/src/site-docs/adoc/fragments/howto-logging/standard-configuration.adoc
blob: 4cd4b9b67860709ac8dc24c1b3bf4361d7dcaf62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// ============LICENSE_START=======================================================
//  Copyright (C) 2016-2018 Ericsson. All rights reserved.
// ================================================================================
// This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE
// Full license text at https://creativecommons.org/licenses/by/4.0/legalcode
// 
// SPDX-License-Identifier: CC-BY-4.0
// ============LICENSE_END=========================================================
//
// @author Sven van der Meer (sven.van.der.meer@ericsson.com)
//

== Standard Logging Configuration

The standard logging configuration defines a context __APEX__, which is used in the standard output pattern.
The location for log files is defined in the property `VAR_LOG` and set to `/var/log/onap/policy/apex-pdp`.
The standard status listener is set to __NOP__ and the overall logback configuration is set to no debug.

[source%nowrap,xml,numbered]
----
<configuration debug="false">
  <statusListener class="ch.qos.logback.core.status.NopStatusListener" />

  <contextName>Apex</contextName>
  <property name="VAR_LOG" value="/var/log/onap/policy/apex-pdp/" />

  ...appenders
  ...loggers
</configuration>
----

The first appender defined is called `STDOUT` for logs to standard out.

[source%nowrap,xml,numbered]
----
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  <encoder>
    <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
  </encoder>
</appender>
----

The root level logger then is set to the level __info__ using the standard out appender.
[source%nowrap,xml,numbered]
----
<root level="info">
  <appender-ref ref="STDOUT" />
</root>
----

The second appender is called `FILE`.
It writes logs to a file `apex.log`.
[source%nowrap,xml,numbered]
----
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
  <file>${VAR_LOG}/apex.log</file>
  <encoder>
    <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
  </encoder>
</appender>
----

The third appender is called `CTXT_FILE`.
It writes logs to a file `apex_ctxt.log`.
[source%nowrap,xml,numbered]
----
<appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
  <file>${VAR_LOG}/apex_ctxt.log</file>
  <encoder>
    <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level %logger{26} - %msg %n %ex{full}</pattern>
  </encoder>
</appender>
----

The last definitions are for specific loggers.
The first logger captures all standard APEX classes.
It is configured for log level __info__ and uses the standard output and file appenders.
The second logger captures APEX context classes responsible for context monitoring.
It is configured for log level __trace__ and uses the context file appender.

[source%nowrap,xml,numbered]
----
<logger name="org.onap.policy.apex" level="info" additivity="false">
  <appender-ref ref="STDOUT" />
  <appender-ref ref="FILE" />
</logger>

<logger name="org.onap.policy.apex.core.context.monitoring" level="TRACE" additivity="false">
  <appender-ref ref="CTXT_FILE" />
</logger>
----