This file is indexed.

/usr/share/doc/red5/html/logging-setup.html is in red5-doc 1.0~svn4374-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Chapter&nbsp;10.&nbsp;Logging Setup</title><link rel="stylesheet" type="text/css" href="html.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Red5 - Reference Documentation"><link rel="up" href="core-components.html" title="Part&nbsp;II.&nbsp;Red5 Core Components"><link rel="prev" href="new-applications.html" title="Chapter&nbsp;9.&nbsp;Create new applications in Red5"><link rel="next" href="tomcat-deployment.html" title="Chapter&nbsp;11.&nbsp;Deploying Red5 To Tomcat"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" style="background-color:white;border:none;height:73px;border:1px solid black;"><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;" src="images/red5-banner.png"></img></a><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;position:absolute;padding-top:5px;right:42px;" src="images/red5-banner-logo.png"></img></a></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="logging-setup"></a>Chapter&nbsp;10.&nbsp;Logging Setup</h2></div></div></div>
	
	<p>The logging system uses Simple Logging Facade for Java (
		<a class="ulink" href="http://www.slf4j.org/" target="_top">SLF4J</a>). This framework supports many of the logging systems available for Java and also provides simple implementations. The logging used by our dependencies are mainly Log4j and Apache commons logging and SLF4J allows us to combine them into one system. SLF4J gives you the ability to select a logging implementation and provides proxies for you dependencies if their maintainers did not select the same framework.
	</p>
	<p>We prefer the 
		<a class="ulink" href="http://logback.qos.ch/" target="_top">logback</a> log implementation, but you may use whatever you like. There are some hoops you will have to jump through to get 
		<a class="ulink" href="http://logging.apache.org/" target="_top">Log4j</a> or 
		<a class="ulink" href="http://commons.apache.org/logging/" target="_top">Commons logging</a> to work. Blog post about using other loggers 
		<a class="ulink" href="http://gregoire.org/2009/05/05/support-for-other-slf4j-loggers/" target="_top">here</a>.
	</p>
	<p>After you chose an implementation framework, some of the SLF4J jars must 
		<span class="bold"><strong>NOT</strong></span> be in your applications classpath or they will cause conflicts. The default case it to use Logback, so the following jars must be included:
	</p>
	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
			<p>slf4j-api - The core API</p>
		</li><li class="listitem">
			<p>logback-core - Current Logback core library</p>
		</li><li class="listitem">
			<p>logback-classic - Logback support library</p>
		</li><li class="listitem">
			<p>log4j-over-slf4j - Log4j proxy/bridge</p>
		</li><li class="listitem">
			<p>jcl-over-slf4j - Apache commons logging proxy/bridge</p>
		</li><li class="listitem">
			<p>jul-to-slf4j - java.util.logging proxy/bridge</p>
		</li></ul></div>
	<p>The items denoted as "proxy/bridge" listen for the logging calls to those implementations and pass them through to SLF4J.</p>
	<p>The following two strategies are to be consider 
		<span class="bold"><strong>untested</strong></span>.
	</p>
	<p>If you prefer to use Log4j instead, the following jars are required:</p>
	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
			<p>slf4j-api - The core API</p>
		</li><li class="listitem">
			<p>log4j - Current Log4j library (1.2+)</p>
		</li><li class="listitem">
			<p>slf4j-log4j12 - Log4j adapter</p>
		</li><li class="listitem">
			<p>jcl-over-slf4j - Apache commons logging proxy/bridge</p>
		</li><li class="listitem">
			<p>jul-to-slf4j - java.util.logging proxy/bridge</p>
		</li></ul></div>
	<p>If you prefer to use Commons logging the following jars are required:</p>
	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
			<p>slf4j-api - The core API</p>
		</li><li class="listitem">
			<p>commons-logging - Apache commons logging library</p>
		</li><li class="listitem">
			<p>slf4j-jcl - Commons logging adapter</p>
		</li><li class="listitem">
			<p>log4j-over-slf4j - Log4j proxy/bridge</p>
		</li><li class="listitem">
			<p>jul-to-slf4j - java.util.logging proxy/bridge</p>
		</li></ul></div>
	<p>If you want to use another implementation not shown here, simply check out the faq 
		<a class="ulink" href="http://www.slf4j.org/faq.html" target="_top">SLF4J FAQ</a>
	</p>
	<p>Logback is the successor of Log4j and was created by the creator of Log4j and SLF4J. A conversion tool has been created for your log4j properties files 
		<a class="ulink" href="http://logback.qos.ch/translator/Welcome.do" target="_top">configuration converter</a>
		There is also an eclipse console plugin 
		<a class="ulink" href="http://logback.qos.ch/consolePlugin.html" target="_top">eclipse console plugin</a>.
	</p>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1586"></a>10.1.&nbsp;Web applications</h2></div></div></div>
		
		<p>In your web applications remove the following entry from your web.xml</p>
		<pre class="programlisting">


&lt;context-param&gt;
  &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
  &lt;param-value&gt;/WEB-INF/log4j.properties&lt;/param-value&gt;
&lt;/context-param&gt;

</pre>
		<p>Add the following to the web.xml</p>
		<pre class="programlisting">


&lt;listener&gt;
    &lt;listener-class&gt;org.red5.logging.ContextLoggingListener&lt;/listener-class&gt;
&lt;/listener&gt;

&lt;filter&gt;
    &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;org.red5.logging.LoggerContextFilter&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
    &lt;filter-name&gt;LoggerContextFilter&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

</pre>
		<p>You should also:</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>Remove any "log4j" listeners from the web.xml</p>
			</li><li class="listitem">
				<p>Remove any log4j.properties or log4j.xml files</p>
			</li><li class="listitem">
				<p>Create a logback-myApp.xml where myApp is the name for your webapp and place it on your webapp classpath (WEB-INF/classes or in your application jar within WEB-INF/lib)</p>
			</li><li class="listitem">
				<p>Set your display-name in the web application to match the context name you will be using (Use the example oflaDemo as a guide).</p>
			</li><li class="listitem">
				<p>Ensure that the contextName and jmxConfigurator have the correct context name, this is the name of your web application</p>
			</li></ul></div>
		<p>Sample webapp logback config file (logback-myApp.xml), not to be confused with the red5 log config file located in /conf</p>
		<pre class="programlisting">


&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;configuration&gt;	
    &lt;contextName&gt;myApp&lt;/contextName&gt;
    &lt;jmxConfigurator contextName="myApp" /&gt;    

    &lt;appender name="FILE" class="ch.qos.logback.core.FileAppender"&gt;
        &lt;File&gt;example.log&lt;/File&gt;
        &lt;Append&gt;false&lt;/Append&gt;
        &lt;BufferedIO&gt;false&lt;/BufferedIO&gt;
        &lt;ImmediateFlush&gt;true&lt;/ImmediateFlush&gt;
        &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
            &lt;Pattern&gt;%-4relative [%thread] %-5level %logger{35} - %msg%n&lt;/Pattern&gt;
        &lt;/layout&gt;
    &lt;/appender&gt;
    &lt;root&gt;
        &lt;level value="DEBUG" /&gt;
        &lt;appender-ref ref="FILE" /&gt;
    &lt;/root&gt;
    &lt;logger name="com.example"&gt;
        &lt;level value="DEBUG" /&gt;
    &lt;/logger&gt;
&lt;/configuration&gt;

</pre>
		<p>
			<span class="bold"><strong>Reminder</strong></span> replace everything that says "myApp" with your application name.
		</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1608"></a>10.2.&nbsp;Imports</h2></div></div></div>
		
		<p>When using logback and slf4j, your imports should consist only of the following for a non webapp class:</p>
		<pre class="programlisting">


import org.slf4j.LoggerFactory;
import org.slf4j.Logger;

</pre>
		<p>It is suggested that you use Red5LoggerFactory in-place of LoggerFactory to ensure that your application gets the correct logger.</p>
		<p>For loggers inside your webapp imports should be:</p>
		<pre class="programlisting">


import org.slf4j.Logger;
import org.red5.logging.Red5LoggerFactory;

</pre>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="LoggingSetupLoggerInstantiation"></a>10.3.&nbsp;Logger Instantiation</h2></div></div></div>
		
		<p>For non webapp classes:</p>
		<p>To log to a "root" logger, change all your logger instantiation statements to:</p>
		<pre class="programlisting">


private static Logger log = Red5LoggerFactory.getLogger(MyClassName.class);

</pre>
		<p>
			<span class="bold"><strong>Reminder</strong></span> replace "MyClassName" with the name of the class itself.
		</p>
		<p>To log to a "context" logger, change all your logger instantiation statements to:</p>
		<pre class="programlisting">


private static Logger log = Red5LoggerFactory.getLogger(MyClassName.class, "myApp");

</pre>
		<p>
			<span class="bold"><strong>Reminder</strong></span> replace "myApp" with the name of the context; "myApp" would become "oflaDemo" for the oflaDemo application.
		</p>
		<p>Your old instantiations probably resemble this:</p>
		<pre class="programlisting">


private static Logger log = Logger.getLogger(MyClassName.class.getName());

</pre>
		<p>Your applications logging configuration file must contain the name of your application context in its file name; For instance the "oflaDemo" uses the configuration logback-oflaDemo.xml. </p>
		<p>Lastly, as an optimation change your log statements to:</p>
		<pre class="programlisting">


log.debug("Here is a log message for an object {}", myobject);

</pre>
		<p>You no longer need to concatenate strings when logging, if you need more than one variable do the following:</p>
		<pre class="programlisting">


log.debug("Here is a log message with a couple vars {} or {} or {}", new Object[] {object1, myobject, object3});

</pre>
		<p>= Further Information =</p>
		<p>
			<a class="ulink" href="http://jazoon.com/en/conference/presentationdetails.html?type=sid&amp;detail=6080" target="_top">Ceki G&uuml;lc&uuml;  presentation for Jazoon09</a>
		</p>
		<p>
			<a class="ulink" href="http://beta.parleys.com/share/parleysshare2.swf?pageId=357" target="_top">SLF4J Presentation (video)</a>
		</p>
	</div>
</div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="new-applications.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="tomcat-deployment.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;9.&nbsp;Create new applications in Red5&nbsp;</td><td width="20%" align="center"><span style="color:white;font-size:90%;"><a href="http://osflash.org/red5" title="Red5">Red5 Open Source Flash Server</a></span></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;11.&nbsp;Deploying Red5 To Tomcat</td></tr></table></div></body></html>