qsg.xml
5.61 KB
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
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>
<properties>
<author email="marco at apache dot org">Marco Vassura</author>
<title>Log4php - Quick Setup Guide</title>
</properties>
<meta name="keywords" content="php, java, logging, tracing, component, framework, API, log4php"/>
<body>
<section name="Quick Setup Guide">
<subsection name="The package tree">
<p>After unpacking the distribution file the following source tree will be created:</p>
<pre>
log4php-{version}
+---docs
| +---api
| qsg.html (this file)
| ...
\---src
+---log4php
| +---appenders
| +---config
| +---helpers
| +---layouts
| +---or
| +---spi
| +---varia
| \---xml
\---tests
...
</pre>
</subsection>
<subsection name="Installation">
<p>
Copy the "<code>log4php-{version}/src/log4php</code>" directory in a place accessible by PHP
(called in this document <code>{LOG4PHP-ROOT}</code>)
and that's all! Log4php is installed.
Optionally the <a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_DIR">LOG4PHP_DIR</a>
constant can be defined to point to <code>{LOG4PHP-ROOT}</code>.
</p>
</subsection>
<subsection name="How to use">
<p>
Three steps are required to use log4php:
</p>
<ol>
<li>
Create a configuration file (can be an ".ini"-type or xml file)
that will configure the log4php loggers hierarchy tree.<br/>
See the <code>tests/*/configs</code> directories for examples.<br/>
See <code>log4php.dtd</code> for xml elements reference.<br/>
Finally, take a look at the original log4j manual for more examples.
</li>
<li>
(Optional) Define the <a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_CONFIGURATION"><code>LOG4PHP_CONFIGURATION</code></a>
constant to point to the configuration above.
</li>
<li>
(Optional) Define the <a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_CONFIGURATOR_CLASS"><code>LOG4PHP_CONFIGURATOR_CLASS</code></a>
constant to point to a configuration class file.
</li>
<li>
Include the '<a href="apidocs/log4php/LoggerManager.html"><code>LoggerManager.php</code></a>'
class file in your php scripts.
</li>
<li>
Since log4php makes use of date functions, it is recommended that you have set:
date_default_timezone_set(); somewhere within your application.
</li>
</ol>
<p>
Once the '<a href="apidocs/log4php/LoggerManager.html">LoggerManager</a>' is included,
it will start the <a href="apidocs/log4php/_LoggerManager.php.html#functionLoggerManagerDefaultInit">default init procedure</a>
that can be parameterized by the previously defined
<a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_DEFAULT_INIT_OVERRIDE"><code>LOG4PHP_DEFAULT_INIT_OVERRIDE</code></a>,
<a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_CONFIGURATION"><code>LOG4PHP_CONFIGURATION</code></a> and
<a href="apidocs/log4php/_LoggerManager.php.html#defineLOG4PHP_CONFIGURATOR_CLASS"><code>LOG4PHP_CONFIGURATOR_CLASS</code></a>
constants.
</p>
<p>Here is how to use <code>log4php</code> in user PHP code:</p>
<pre>
<?php
// Setting default timezone
date_default_timezone_set('Europe/London');
/*
Set LOG4PHP_* constants here
*/
require_once(LOG4PHP_DIR . '/LoggerManager.php');
/*
In a class
*/
class Log4phpTest {
/*
Your public and private vars
*/
var $_logger;
function Log4phpTest()
{
$this->_logger =& LoggerManager::getLogger('Log4phpTest');
$this->_logger->debug('Hello!');
}
}
function Log4phpTestFunction()
{
$logger =& LoggerManager::getLogger('Log4phpTestFunction');
$logger->debug('Hello again!');
}
/*
Your PHP code
*/
//Safely close all appenders with...
LoggerManager::shutdown();
?>
</pre>
</subsection>
</section>
</body>
</document>