forked from RedhawkSDR/Documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainch18.html
306 lines (287 loc) · 14.9 KB
/
mainch18.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title>18 Logging</title>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html,2,next,javascript,charset="utf-8" -->
<meta name="src" content="main.tex">
<meta name="date" content="2013-03-12 19:46:00">
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="scripts/shCore.js"></script>
<script type="text/javascript" src="scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="scripts/shBrushJava.js"></script>
<script type="text/javascript" src="scripts/shBrushPython.js"></script>
<script type="text/javascript" src="scripts/shBrushBash.js"></script>
<script type="text/javascript" src="scripts/shBrushXml.js"></script>
<link href="styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</head><body
>
<script>
function f() {
document.getElementById('main_content_wrap').focus();
}
if (window.addEventListener) {
window.addEventListener("load", f, false);
} else if (window.attachEvent) {
window.attachEvent("onload", f);
}
</script>
<div class="header">
<ul class="navbar">
<li><a class="logo-small" href="index.html"><img src="images/RedHawk_Logo_ALT_B_121px.png"/></a></li> <li><a href="index.html">Home</a></li>
<li><a href="gettingstarted/main.html">Getting Started</a></li>
<li><a class="active" href="main.html">Documentation</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="support.html">Support</a></li>
</ul>
<div class="pattern right"></div>
<a id="forkme_banner" href="https://github.com/redhawksdr">View on GitHub</a>
</div>
<!-- Custom MAIN CONTENT -->
<div id="main_content_wrap" tabindex="0" class="outer">
<section id="main_content" class="inner">
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainch19.html" >next</a>] [<a
href="mainch17.html" >prev</a>] [<a
href="mainch17.html#tailmainch17.html" >prev-tail</a>] [<a
href="#tailmainch18.html">tail</a>] [<a
href="main.html#mainch18.html" >up</a>] </p></div>
<h2 class="chapterHead"><span class="titlemark">Chapter 18</span><br /><a
id="x20-24300018"></a>Logging</h2>
<h3 class="sectionHead"><span class="titlemark">18.1 </span> <a
id="x20-24400018.1"></a>Introduction</h3>
<!--l. 5--><p class="noindent" >REDHAWK provides a logging interface for use by Resources (e.g., <a
href="mainli2.html#glo:component">Components</a> and <a
href="mainli2.html#glo:device">Devices</a>). The
details of the logging functionality can be found in the documentation for the respective underlying
third-party libraries. This chapter addresses the basic use and configuration of logging in the
REDHAWK context.
<!--l. 9--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">18.2 </span> <a
id="x20-24500018.2"></a>Dependencies</h3>
<!--l. 10--><p class="noindent" >REDHAWK utilizes log4cxx, log4j, and log4py for C++, Java, and Python, respectively.
<!--l. 12--><p class="noindent" >For more information on each of these libraries, consult the following web pages:
<ul class="itemize1">
<li class="itemize"><a
href="http://logging.apache.org/log4cxx/" >http://logging.apache.org/log4cxx/</a>
</li>
<li class="itemize"><a
href="http://logging.apache.org/log4j/2.x/" >http://logging.apache.org/log4j/2.x/</a>
</li>
<li class="itemize"><a
href="https://github.com/maihde/log4py/" >https://github.com/maihde/log4py/</a></li></ul>
<!--l. 18--><p class="noindent" >In all languages, the third-party libraries provide multiple log levels. The configuration of the
REDHAWK logger will determine which levels of messages appear in the log.
<!--l. 21--><p class="noindent" >Below are the available logging levels listed in order of increasing verbosity:
<ul class="itemize1">
<li class="itemize"><span
class="cmtt-12">OFF</span>
</li>
<li class="itemize"><span
class="cmtt-12">FATAL</span>
</li>
<li class="itemize"><span
class="cmtt-12">ERROR</span>
</li>
<li class="itemize"><span
class="cmtt-12">WARN</span>
</li>
<li class="itemize"><span
class="cmtt-12">INFO</span>
</li>
<li class="itemize"><span
class="cmtt-12">DEBUG</span>
</li>
<li class="itemize"><span
class="cmtt-12">TRACE</span>
</li>
<li class="itemize"><span
class="cmtt-12">ALL</span></li></ul>
<!--l. 35--><p class="noindent" >The log level configuration of the system will indicate the highest level of verbosity that
will appear in the log. For example, if the log level is set to the default (<span
class="cmtt-12">INFO</span>), then
messages at the <span
class="cmtt-12">INFO</span>, <span
class="cmtt-12">WARN</span>, <span
class="cmtt-12">ERROR</span>, and <span
class="cmtt-12">FATAL </span>levels will appear in the log. Note that <span
class="cmtt-12">OFF</span>
and <span
class="cmtt-12">ALL </span>are special cases: the system may be configured to log all (<span
class="cmtt-12">ALL</span>) or none (<span
class="cmtt-12">OFF</span>)
of the log messages, but a particular message may not be logged at log levels <span
class="cmtt-12">ALL </span>or
<span
class="cmtt-12">OFF</span>.
<!--l. 39--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">18.3 </span> <a
id="x20-24600018.3"></a>Configuration</h3>
<!--l. 41--><p class="noindent" >By default, the logging feature is configured to write log messages of level <span
class="cmtt-12">INFO </span>or greater to
standard out.
<!--l. 43--><p class="noindent" >To change the default configuration, a configuration file may be passed to <span
class="cmtt-12">nodeBooter </span>using the
following command-line argument:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
-logcfgfile sca:/<logging config file>
]]></script>
<!--l. 49--><p class="noindent" >Passing the argument when starting up a <a
href="mainli2.html#glo:node">Node</a> (i.e., when starting <span
class="cmtt-12">nodeBooter </span>with the <span
class="cmtt-12">-d</span>
argument) will set the logging configuration for all <a
href="mainli2.html#glo:device">Devices</a> managed by the <a
href="mainli2.html#glo:devicemanager">Device Manager</a> as
well as for the <a
href="mainli2.html#glo:devicemanager">Device Manager</a> itself. In this case, the logging file is located relative to
<span
class="cmtt-12">$SDRROOT/dev</span>.
<!--l. 52--><p class="noindent" >Passing the argument when starting up the <a
href="mainli2.html#glo:domainmanager">Domain Manager</a> (i.e., when starting <span
class="cmtt-12">nodeBooter </span>with
the <span
class="cmtt-12">-D </span>argument) will set the logging configuration for everything in the system apart from
<a
href="mainli2.html#glo:devicemanager">Device Managers</a>s and <a
href="mainli2.html#glo:device">Devices</a>. In this case, the logging config file is located relative to
<span
class="cmtt-12">$SDRROOT/dom</span>.
<!--l. 55--><p class="noindent" >Passing the argument when starting up the <a
href="mainli2.html#glo:devicemanager">Device Manager</a> and <a
href="mainli2.html#glo:domainmanager">Domain Manager</a> simultaneously
(i.e., when starting <span
class="cmtt-12">nodeBooter </span>with the <span
class="cmtt-12">-d </span>and <span
class="cmtt-12">-D </span>arguments) will set the logging configuration
for the entire system.
<!--l. 57--><p class="noindent" >Below is an example log4j configuration file:
<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
# Set root logger default levels and appender
log4j.rootLogger=DEBUG, CONSOLE, FILE
# Console Appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.STDERR=org.apache.log4j.ConsoleAppender
log4j.appender.STDERR.Threshold=ERROR
log4j.appender.STDERR.Target=System.err
# Default Log Appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.Append=true
# Edet Appender
log4j.appender.edetLog=org.apache.log4j.FileAppender
log4j.appender.edetLog.Append=true
# Appender layout
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601}:
%p:%c - %m [%F:%L]%n
log4j.appender.STDERR.layout=org.apache.log4j.PatternLayout
log4j.appender.STDERR.layout.ConversionPattern=%d{ISO8601}:
%p:%c - %m [%F:%L]%n
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{ISO8601}:
%p:%c - %m [%F:%L]%n
log4j.appender.edetLog.layout=org.apache.log4j.PatternLayout
log4j.appender.edetLog.layout.ConversionPattern=%d{ISO8601}:
%p:%c - %m [%F:%L]%n
log4j.appender.NULL.layout=org.apache.log4j.PatternLayout
log4j.appender.NULL.layout.ConversionPattern=%n
log4j.category.Foo_cpp_impl1_i=DEBUG, edetLog
log4j.additivity.Foo_cpp_impl1_i=false
]]></script>
<!--l. 97--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">18.4 </span> <a
id="x20-24700018.4"></a>Use Within Resources</h3>
<!--l. 98--><p class="noindent" >Code generated using the REDHAWK <a
href="mainap3.html#ide">IDE</a> should contain all necessary prerequisites for using log
methods as well as example calls to the log methods. Should auto-generated code not be available,
this section provides a description of the use of the log modules in C++, Java, and
Python.
<h4 class="subsectionHead"><span class="titlemark">18.4.1 </span> <a
id="x20-24800018.4.1"></a>C++</h4>
<!--l. 102--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-24900018.4.1"></a>Setup</h5>
<!--l. 103--><p class="noindent" >All necessary include statements are inherited from the Resource base class.
<!--l. 105--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-25000018.4.1"></a>Use</h5>
<!--l. 107--><p class="noindent" >An example logging method call for use in C++ is: <script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
LOG_DEBUG(complexCpp_i, "serviceFunction() example log message");
]]></script>
<!--l. 112--><p class="noindent" >Note that the word “<span
class="cmtt-12">DEBUG</span>” may be replaced with any of the logging levels between <span
class="cmtt-12">FATAL </span>and
<span
class="cmtt-12">TRACE </span>(see <a
href="#x20-24500018.2">Section 18.2</a>).
<!--l. 115--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">18.4.2 </span> <a
id="x20-25100018.4.2"></a>Java</h4>
<!--l. 116--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-25200018.4.2"></a>Setup</h5>
<!--l. 117--><p class="noindent" >The log4j Logger module must be imported for use: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
import org.apache.log4j.Logger;
]]></script>
<!--l. 122--><p class="noindent" >A class data field of type <span
class="cmtt-12">Logger </span>should then be created:
<script type="syntaxhighlighter" class="brush: java"><![CDATA[
public final static Logger logger =
Logger.getLogger(myComponentClass.class.getName());
]]></script>
<!--l. 129--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-25300018.4.2"></a>Use</h5>
<!--l. 130--><p class="noindent" >An example logging method call for Java is: <script type="syntaxhighlighter" class="brush: java"><![CDATA[
logger.debug("run() example log message");
]]></script>
Note that the word “<span
class="cmtt-12">debug</span>” may be replaced with any of the logging levels between <span
class="cmtt-12">FATAL </span>and
<span
class="cmtt-12">TRACE </span>(lower case).
<!--l. 137--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">18.4.3 </span> <a
id="x20-25400018.4.3"></a>Python</h4>
<!--l. 138--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-25500018.4.3"></a>Setup</h5>
<!--l. 140--><p class="noindent" >A <a
href="mainli2.html#glo:component">Component</a> inheriting from the REDHAWK Python Resource class will inherit a <span
class="cmtt-12">_log </span>data
field.
<!--l. 142--><p class="noindent" >
<h5 class="subsubsectionHead"><a
id="x20-25600018.4.3"></a>Use</h5>
<!--l. 143--><p class="noindent" >An example logging method call for Python is: <script type="syntaxhighlighter" class="brush: python"><![CDATA[
self._log.debug("process() example log message")
]]></script>
<!--l. 148--><p class="noindent" >Note that the word “<span
class="cmtt-12">debug</span>” may be replaced with any of the logging levels between <span
class="cmtt-12">FATAL </span>and
<span
class="cmtt-12">TRACE </span>(lower case).
<!--l. 150--><p class="noindent" >Optionally, a developer can make direct calls to the logger module. Below is an example of using the logger directly: <script type="syntaxhighlighter" class="brush: python"><![CDATA[
import logging
logging.getLogger().setLevel(logging.WARN)
logging.debug("Starting Component")
]]></script>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
href="mainch19.html" >next</a>] [<a
href="mainch17.html" >prev</a>] [<a
href="mainch17.html#tailmainch17.html" >prev-tail</a>] [<a
href="mainch18.html" >front</a>] [<a
href="main.html#mainch18.html" >up</a>] </p></div>
<!--l. 1--><p class="noindent" ><a
id="tailmainch18.html"></a>
<div class=license>
<hr>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" /></a><br /><span xmlns:dct="http:// purl.org/dc/terms/" property="dct:title">REDHAWK Documentation</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
</div>
</body></html>