├── .gitignore ├── CHANGELOG ├── INSTALL ├── LICENSE ├── NOTICE ├── README ├── apigen.neon ├── build.xml ├── composer.json ├── doap_log4php.rdf ├── package-config.php ├── package.php ├── phpdoc.xml ├── phpunit.xml ├── pom.xml └── src ├── assembly └── src.xml ├── changes └── changes.xml ├── examples ├── php │ ├── appender_console.php │ ├── appender_dailyfile.php │ ├── appender_echo.php │ ├── appender_file.php │ ├── appender_firephp.php │ ├── appender_mail.php │ ├── appender_mailevent.php │ ├── appender_mongodb.php │ ├── appender_null.php │ ├── appender_pdo.php │ ├── appender_php.php │ ├── appender_rollingfile.php │ ├── appender_socket.php │ ├── appender_socket_server.php │ ├── appender_syslog.php │ ├── cache.php │ ├── configurator_basic.php │ ├── configurator_php.php │ ├── configurator_xml.php │ ├── filter_denyall.php │ ├── filter_levelmatch.php │ ├── filter_levelrange.php │ ├── filter_stringmatch.php │ ├── layout_html.php │ ├── layout_pattern.php │ ├── layout_simple.php │ ├── layout_ttcc.php │ ├── layout_xml.php │ ├── mdc.php │ ├── ndc.php │ ├── renderer_default.php │ ├── renderer_map.php │ └── simple.php └── resources │ ├── appender_console.properties │ ├── appender_dailyfile.properties │ ├── appender_echo.properties │ ├── appender_file.properties │ ├── appender_firephp.xml │ ├── appender_mail.properties │ ├── appender_mailevent.properties │ ├── appender_mongodb.xml │ ├── appender_null.properties │ ├── appender_pdo.properties │ ├── appender_php.properties │ ├── appender_rollingfile.properties │ ├── appender_socket.properties │ ├── appender_socket_server.properties │ ├── appender_syslog.properties │ ├── cache.properties │ ├── configurator_php.php │ ├── configurator_xml.xml │ ├── filter_denyall.xml │ ├── filter_levelmatch.xml │ ├── filter_levelrange.xml │ ├── filter_stringmatch.xml │ ├── layout_html.properties │ ├── layout_pattern.properties │ ├── layout_simple.properties │ ├── layout_ttcc.properties │ ├── layout_xml.properties │ ├── mdc.properties │ ├── ndc.properties │ ├── renderer_default.properties │ └── renderer_map.properties ├── main └── php │ ├── Logger.php │ ├── LoggerAppender.php │ ├── LoggerAppenderPool.php │ ├── LoggerAutoloader.php │ ├── LoggerConfigurable.php │ ├── LoggerConfigurator.php │ ├── LoggerException.php │ ├── LoggerFilter.php │ ├── LoggerHierarchy.php │ ├── LoggerLayout.php │ ├── LoggerLevel.php │ ├── LoggerLocationInfo.php │ ├── LoggerLoggingEvent.php │ ├── LoggerMDC.php │ ├── LoggerNDC.php │ ├── LoggerReflectionUtils.php │ ├── LoggerRoot.php │ ├── LoggerThrowableInformation.php │ ├── appenders │ ├── LoggerAppenderConsole.php │ ├── LoggerAppenderDailyFile.php │ ├── LoggerAppenderEcho.php │ ├── LoggerAppenderFile.php │ ├── LoggerAppenderFirePHP.php │ ├── LoggerAppenderMail.php │ ├── LoggerAppenderMailEvent.php │ ├── LoggerAppenderMongoDB.php │ ├── LoggerAppenderNull.php │ ├── LoggerAppenderPDO.php │ ├── LoggerAppenderPhp.php │ ├── LoggerAppenderRollingFile.php │ ├── LoggerAppenderSocket.php │ └── LoggerAppenderSyslog.php │ ├── configurators │ ├── LoggerConfigurationAdapter.php │ ├── LoggerConfigurationAdapterINI.php │ ├── LoggerConfigurationAdapterPHP.php │ ├── LoggerConfigurationAdapterXML.php │ └── LoggerConfiguratorDefault.php │ ├── filters │ ├── LoggerFilterDenyAll.php │ ├── LoggerFilterLevelMatch.php │ ├── LoggerFilterLevelRange.php │ └── LoggerFilterStringMatch.php │ ├── helpers │ ├── LoggerFormattingInfo.php │ ├── LoggerOptionConverter.php │ ├── LoggerPatternParser.php │ └── LoggerUtils.php │ ├── layouts │ ├── LoggerLayoutHtml.php │ ├── LoggerLayoutPattern.php │ ├── LoggerLayoutSerialized.php │ ├── LoggerLayoutSimple.php │ ├── LoggerLayoutTTCC.php │ └── LoggerLayoutXml.php │ ├── pattern │ ├── LoggerPatternConverter.php │ ├── LoggerPatternConverterClass.php │ ├── LoggerPatternConverterCookie.php │ ├── LoggerPatternConverterDate.php │ ├── LoggerPatternConverterEnvironment.php │ ├── LoggerPatternConverterFile.php │ ├── LoggerPatternConverterLevel.php │ ├── LoggerPatternConverterLine.php │ ├── LoggerPatternConverterLiteral.php │ ├── LoggerPatternConverterLocation.php │ ├── LoggerPatternConverterLogger.php │ ├── LoggerPatternConverterMDC.php │ ├── LoggerPatternConverterMessage.php │ ├── LoggerPatternConverterMethod.php │ ├── LoggerPatternConverterNDC.php │ ├── LoggerPatternConverterNewLine.php │ ├── LoggerPatternConverterProcess.php │ ├── LoggerPatternConverterRelative.php │ ├── LoggerPatternConverterRequest.php │ ├── LoggerPatternConverterServer.php │ ├── LoggerPatternConverterSession.php │ ├── LoggerPatternConverterSessionID.php │ ├── LoggerPatternConverterSuperglobal.php │ └── LoggerPatternConverterThrowable.php │ ├── renderers │ ├── LoggerRenderer.php │ ├── LoggerRendererDefault.php │ ├── LoggerRendererException.php │ └── LoggerRendererMap.php │ └── xml │ └── log4php.dtd ├── site ├── apt │ ├── contributingpatches.apt │ ├── download.apt │ ├── index.apt │ ├── privacy-policy.apt │ └── volunteering.apt ├── cse.xml ├── resources │ ├── css │ │ ├── bootstrap.css │ │ ├── bootstrap.min.css │ │ └── site.css │ ├── images │ │ ├── collapsed.gif │ │ ├── expanded.gif │ │ └── logos │ │ │ ├── ls-logo.jpg │ │ │ └── maven-feather.png │ ├── img │ │ ├── glyphicons-halflings-white.png │ │ └── glyphicons-halflings.png │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ ├── prettify.js │ │ ├── prettify.min.js │ │ └── site.js ├── site.vm ├── site.xml └── xdoc │ ├── changelog.xml │ ├── docs │ ├── appenders.xml │ ├── appenders │ │ ├── console.xml │ │ ├── daily-file.xml │ │ ├── echo.xml │ │ ├── file.xml │ │ ├── firephp.xml │ │ ├── mail-event.xml │ │ ├── mail.xml │ │ ├── mongodb.xml │ │ ├── null.xml │ │ ├── pdo.xml │ │ ├── php.xml │ │ ├── rolling-file.xml │ │ ├── socket.xml │ │ └── syslog.xml │ ├── configuration.xml │ ├── filters.xml │ ├── introduction.xml │ ├── layouts.xml │ ├── layouts │ │ ├── html.xml │ │ ├── pattern.xml │ │ ├── serialized.xml │ │ ├── simple.xml │ │ ├── ttcc.xml │ │ └── xml.xml │ ├── loggers.xml │ └── renderers.xml │ ├── install.xml │ ├── privacy.xml │ └── quickstart.xml └── test ├── config └── phpunit_to_surefire.xslt ├── php ├── LoggerAppenderPoolTest.php ├── LoggerAppenderTest.php ├── LoggerConfiguratorTest.php ├── LoggerExceptionTest.php ├── LoggerFilterTest.php ├── LoggerHierarchyTest.php ├── LoggerIdGenerator.php ├── LoggerLevelTest.php ├── LoggerLoggingEventTest.php ├── LoggerMDCTest.php ├── LoggerNDCTest.php ├── LoggerReflectionUtilsTest.php ├── LoggerRootTest.php ├── LoggerTest.php ├── LoggerTestHelper.php ├── LoggerThrowableInformationTest.php ├── README ├── appenders │ ├── LoggerAppenderConsoleTest.php │ ├── LoggerAppenderDailyFileTest.php │ ├── LoggerAppenderEchoTest.php │ ├── LoggerAppenderFileTest.php │ ├── LoggerAppenderFirephpTest.php │ ├── LoggerAppenderMailEventTest.php │ ├── LoggerAppenderMailTest.php │ ├── LoggerAppenderMongoDBTest.php │ ├── LoggerAppenderNullTest.php │ ├── LoggerAppenderPDOTest.php │ ├── LoggerAppenderPhpTest.php │ ├── LoggerAppenderRollingFileTest.php │ ├── LoggerAppenderSocketTest.php │ ├── LoggerAppenderSyslogTest.php │ └── socketServer.php ├── bootstrap.php ├── configurators │ ├── LoggerConfigurationAdapterINITest.php │ ├── LoggerConfigurationAdapterPHPTest.php │ └── LoggerConfigurationAdapterXMLTest.php ├── filters │ ├── LoggerFilterDenyAllTest.php │ ├── LoggerFilterLevelMatchTest.php │ ├── LoggerFilterLevelRangeTest.php │ └── LoggerFilterStringMatchTest.php ├── helpers │ ├── LoggerOptionConverterTest.php │ ├── LoggerPatternParserTest.php │ └── LoggerUtilsTest.php ├── layouts │ ├── LoggerLayoutHtmlTest.php │ ├── LoggerLayoutPatternTest.php │ ├── LoggerLayoutSerializedTest.php │ ├── LoggerLayoutSimpleTest.php │ ├── LoggerLayoutTTCCTest.php │ └── LoggerLayoutXmlTest.php ├── pattern │ └── LoggerPatternConverterTest.php └── renderers │ └── LoggerRendererMapTest.php └── resources └── configs ├── adapters ├── ini │ ├── config_invalid_appender_declaration_1.ini │ ├── config_invalid_appender_declaration_2.ini │ ├── config_invalid_syntax.ini │ ├── config_valid.ini │ └── values.ini ├── php │ ├── config_empty.php │ ├── config_invalid_syntax.php │ ├── config_not_an_array.php │ └── config_valid.php └── xml │ ├── config_duplicate_logger.xml │ ├── config_duplicate_renderer.xml │ ├── config_invalid_syntax.xml │ ├── config_valid.xml │ └── config_valid_underscore.xml ├── appenders ├── config_invalid_appender_class.xml ├── config_invalid_filter_class.xml ├── config_invalid_filter_parameters.xml ├── config_invalid_layout_class.xml ├── config_no_class.xml ├── config_no_layout_class.xml ├── config_not_existing_class.xml ├── config_not_existing_filter_class.xml └── config_not_existing_layout_class.xml ├── config.yml ├── config1.xml ├── loggers ├── config_invalid_additivity.xml └── config_not_existing_appenders.xml └── renderers ├── config_default_renderer.xml ├── config_invalid_rendering_class.xml ├── config_no_rendered_class.xml ├── config_no_rendering_class.xml └── config_not_existing_rendering_class.xml /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | temp 3 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | Apache log4php Changelog 2 | ======================== 3 | 4 | Please refer to src/changes/changes.xml for the latest changes. 5 | 6 | Changes for stable versions may be found online at: 7 | http://logging.apache.org/log4php/changelog.html 8 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Licensed to the Apache Software Foundation (ASF) under one or more 2 | contributor license agreements. See the NOTICE file distributed with 3 | this work for additional information regarding copyright ownership. 4 | The ASF licenses this file to You under the Apache License, Version 2.0 5 | (the "License"); you may not use this file except in compliance with 6 | the License. You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | ------------------------------------------------------------------------------ 17 | INSTALLATION 18 | ------------------------------------------------------------------------------ 19 | 20 | 1. Before starting installing this package check if the following external 21 | programs are installed: 22 | 23 | a. PHP (version 5.2.x or above). 24 | 25 | 2. Extract the tarball / zipfile to a dir (ex: {YOUR_PATH}). 26 | 27 | If you want to include log4php under an include_path dir 28 | consider step (a). 29 | 30 | If you want to include log4php wherever you want consider 31 | step (b). 32 | 33 | a. Create a log4php dir under an include_path. 34 | Copy '{YOUR_PATH}/src/main/php' under an '{an_include_path}/log4php'. 35 | 36 | Include the Logger class: 37 | 38 | require_once('log4php/Logger.php'); 39 | 40 | b. Copy '{YOUR_PATH}/src/main/php' to the dir where you want log4php to 41 | reside (ex: {MY_LOG4PHP_PATH}). 42 | 43 | Include the Logger class: 44 | 45 | require_once( '{MY_LOG4PHP_PATH}/Logger.php' ); 46 | 47 | 3. That's all! For more details on using Apache log4php please see the HTML docs in the site folder. 48 | 49 | ------------------------------------------------------------------------------ 50 | $Revision$ 51 | ------------------------------------------------------------------------------ 52 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache log4php 2 | Copyright 2004-2012 The Apache Software Foundation 3 | 4 | This product includes software developed by 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | This project uses GLYPHICONS FREE package, developed by 8 | Jan Kovařík (http://glyphicons.com) 9 | 10 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Apache log4php was moved to dormant status on December 14, 2020. No pull requests or issues will be reviewed or acted upon. 2 | 3 | Apache log4php is a versatile logging framework for PHP. 4 | 5 | Apache log4php is a project at the Apache Software Foundation (ASF). 6 | 7 | Project web site: 8 | http://logging.apache.org/log4php/ 9 | 10 | Project Status 11 | ============== 12 | Apache log4php is a sub project of the Apache Logging Services project. 13 | Apache log4php graduated from the Apache Incubator in March 2010. 14 | -------------------------------------------------------------------------------- /apigen.neon: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | source: src/main/php 17 | destination: target/site/apidocs 18 | charset: UTF-8 19 | title: Apache log4php 20 | progressbar: no 21 | googleAnalytics: UA-26177991-1 22 | php: no 23 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "apache/log4php", 3 | "description": "A versatile logging framework for PHP", 4 | "keywords": ["log", "logging", "php"], 5 | "homepage": "http://logging.apache.org/log4php/", 6 | "type": "library", 7 | "license": "Apache-2.0", 8 | "support": { 9 | "issues": "https://issues.apache.org/jira/browse/LOG4PHP", 10 | "source": "https://svn.apache.org/repos/asf/logging/log4php", 11 | "email": "log4php-user@logging.apache.org" 12 | }, 13 | "autoload": { 14 | "classmap": ["src/main/php/"] 15 | }, 16 | "require": { 17 | "php": ">=5.2.7" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /doap_log4php.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 25 | 26 | 27 | Apache log4php 28 | log4php 29 | Apache log4php is a logging framework for PHP. 30 | 31 | 32 | 33 | 2004-01-06 34 | 35 | 36 | 37 | 38 | 39 | 40 | PHP 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /phpdoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | <![CDATA[Apache log4php]]> 20 | 21 | target/site/apidocs 22 | 23 | php 24 | 25 | 26 | 27 | target/site/apidocs 28 | 29 | 30 | src/main/php 31 | 32 | 33 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 24 | 25 | 26 | src/test/php 27 | 28 | 29 | 30 | 31 | src/main/php 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/assembly/src.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 22 | src 23 | 24 | zip 25 | tar.gz 26 | 27 | apache-log4php-${project.version} 28 | false 29 | 30 | 31 | 32 | LICENSE 33 | NOTICE 34 | README 35 | INSTALL 36 | CHANGELOG 37 | pom.xml 38 | build.xml 39 | package-config.php 40 | package.php 41 | src/** 42 | 43 | 44 | 45 | target/site/apidocs 46 | apidocs 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/examples/php/appender_console.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_dailyfile.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_echo.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_file.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 23 | -------------------------------------------------------------------------------- /src/examples/php/appender_mail.php: -------------------------------------------------------------------------------- 1 | fatal("Some critical message!"); 24 | $logger->fatal("Some more critical message!"); 25 | -------------------------------------------------------------------------------- /src/examples/php/appender_mailevent.php: -------------------------------------------------------------------------------- 1 | fatal("Some critical message!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_mongodb.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 23 | -------------------------------------------------------------------------------- /src/examples/php/appender_null.php: -------------------------------------------------------------------------------- 1 | fatal("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_pdo.php: -------------------------------------------------------------------------------- 1 | fatal("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_php.php: -------------------------------------------------------------------------------- 1 | debug("Hello PHP!"); 23 | -------------------------------------------------------------------------------- /src/examples/php/appender_rollingfile.php: -------------------------------------------------------------------------------- 1 | debug("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_socket.php: -------------------------------------------------------------------------------- 1 | fatal("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/appender_syslog.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/cache.php: -------------------------------------------------------------------------------- 1 | debug('Debug message from cached logger'); 36 | -------------------------------------------------------------------------------- /src/examples/php/configurator_basic.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/configurator_php.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/configurator_xml.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | 25 | -------------------------------------------------------------------------------- /src/examples/php/filter_denyall.php: -------------------------------------------------------------------------------- 1 | info("Some text that will be discarded"); 24 | -------------------------------------------------------------------------------- /src/examples/php/filter_levelmatch.php: -------------------------------------------------------------------------------- 1 | debug("Matching and will be rejected"); 24 | $logger->info("Not matching and will be accepted"); 25 | -------------------------------------------------------------------------------- /src/examples/php/filter_levelrange.php: -------------------------------------------------------------------------------- 1 | debug("This is a debug message"); 24 | $logger->info("This is an info message"); 25 | $logger->warn("This is a warning"); 26 | $logger->error("This is an error"); 27 | $logger->fatal("This is a fatal error"); 28 | -------------------------------------------------------------------------------- /src/examples/php/filter_stringmatch.php: -------------------------------------------------------------------------------- 1 | debug("Some text to match that will be rejected"); 24 | $logger->info("Some other text that will be accepted"); 25 | -------------------------------------------------------------------------------- /src/examples/php/layout_html.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/layout_pattern.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | $logger->debug("Second line"); 25 | -------------------------------------------------------------------------------- /src/examples/php/layout_simple.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/layout_ttcc.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/layout_xml.php: -------------------------------------------------------------------------------- 1 | info("Hello World!"); 24 | -------------------------------------------------------------------------------- /src/examples/php/mdc.php: -------------------------------------------------------------------------------- 1 | debug("Testing MDC"); 25 | -------------------------------------------------------------------------------- /src/examples/php/ndc.php: -------------------------------------------------------------------------------- 1 | debug("just received a new connection"); 25 | LoggerNDC::push('client=ab23'); 26 | $logger->debug("some more messages that can"); 27 | $logger->debug("now related to a client"); 28 | LoggerNDC::pop(); 29 | LoggerNDC::pop(); 30 | $logger->debug("back and waiting for new connections"); 31 | -------------------------------------------------------------------------------- /src/examples/php/renderer_default.php: -------------------------------------------------------------------------------- 1 | lastName . ', ' . $this->firstName; 28 | } 29 | } 30 | 31 | $person = new Person(); 32 | 33 | $logger = Logger::getRootLogger(); 34 | $logger->debug("Now comes the current MyClass object:"); 35 | $logger->debug($person); 36 | -------------------------------------------------------------------------------- /src/examples/php/renderer_map.php: -------------------------------------------------------------------------------- 1 | lastName.', '.$o->firstName; 30 | } 31 | } 32 | 33 | $person = new Person(); 34 | 35 | $logger = Logger::getRootLogger(); 36 | $logger->debug("Now comes the current Person object:"); 37 | $logger->debug($person); -------------------------------------------------------------------------------- /src/examples/php/simple.php: -------------------------------------------------------------------------------- 1 | _logger = Logger::getLogger('Log4phpTest'); 26 | $this->_logger->debug('Hello!'); 27 | } 28 | } 29 | 30 | function Log4phpTestFunction() { 31 | $logger = Logger::getLogger('Log4phpTestFunction'); 32 | $logger->debug('Hello again!'); 33 | } 34 | 35 | $test = new Log4phpTest(); 36 | Log4phpTestFunction(); -------------------------------------------------------------------------------- /src/examples/resources/appender_console.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.console = LoggerAppenderConsole 19 | log4php.appender.console.target = STDOUT 20 | log4php.appender.console.layout = LoggerLayoutSimple 21 | log4php.rootLogger = DEBUG, console 22 | -------------------------------------------------------------------------------- /src/examples/resources/appender_dailyfile.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderDailyFile 19 | log4php.appender.default.layout = LoggerLayoutTTCC 20 | log4php.appender.default.datePattern = Ymd 21 | log4php.appender.default.file = target/examples/daily_%s.log 22 | log4php.rootLogger = DEBUG, default 23 | -------------------------------------------------------------------------------- /src/examples/resources/appender_echo.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutTTCC 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/appender_file.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderFile 19 | log4php.appender.default.file = target/examples/file.log 20 | log4php.appender.default.layout = LoggerLayoutTTCC 21 | log4php.rootLogger = DEBUG, default 22 | -------------------------------------------------------------------------------- /src/examples/resources/appender_firephp.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/examples/resources/appender_mail.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.email = LoggerAppenderMail 19 | log4php.appender.email.layout = LoggerLayoutTTCC 20 | log4php.appender.email.from = someone@example.com 21 | log4php.appender.email.to = root@localhost 22 | log4php.appender.email.subject = Log4php test 23 | log4php.rootLogger = FATAL, email 24 | -------------------------------------------------------------------------------- /src/examples/resources/appender_mailevent.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.email = LoggerAppenderMail 19 | log4php.appender.email.layout = LoggerLayoutTTCC 20 | log4php.appender.email.from = someone@example.com 21 | log4php.appender.email.to = root 22 | log4php.appender.email.subject = Log4php test 23 | log4php.rootLogger = FATAL, email 24 | -------------------------------------------------------------------------------- /src/examples/resources/appender_mongodb.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/examples/resources/appender_null.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderNull 19 | log4php.rootLogger = DEBUG, default 20 | -------------------------------------------------------------------------------- /src/examples/resources/appender_pdo.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.rootLogger = DEBUG, a1, a2, a3 19 | 20 | ; The table is created if necessary and filled using prepared statements. 21 | log4php.appender.a1 = LoggerAppenderPDO 22 | log4php.appender.a1.dsn = "sqlite:target/appender_pdo.sqlite" 23 | 24 | ; The following shows an appender with customized INSERT statment and table name. 25 | log4php.appender.a2 = LoggerAppenderPDO 26 | log4php.appender.a2.user = root 27 | log4php.appender.a2.password = secret 28 | log4php.appender.a2.dsn = "mysql:host=localhost;dbname=test" 29 | log4php.appender.a2.table = log2 30 | log4php.appender.a2.insertSql = "INSERT INTO log2 (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)" 31 | log4php.appender.a2.insertPattern = "%d,%c,%p,%m, %t,%F,%L" 32 | 33 | ; DEPRECATED: Using old style LoggerPatternLayout is considered unsafe as %m can contain quotes that mess up the SQL! 34 | log4php.appender.a3 = LoggerAppenderPDO 35 | log4php.appender.a3.dsn = "sqlite:target/appender_pdo.sqlite" 36 | log4php.appender.a3.table = log3 37 | log4php.appender.a3.sql = "INSERT INTO log3 (timestamp, level, message) VALUES ('%t', '%p', '%m')" 38 | -------------------------------------------------------------------------------- /src/examples/resources/appender_php.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderPhp 19 | log4php.appender.default.layout = LoggerLayoutPattern 20 | log4php.appender.default.layout.conversionPattern = "%d{Y-m-d H:i:s.u} %-5p [%t] %c: %m%n" 21 | log4php.rootLogger = DEBUG, default 22 | -------------------------------------------------------------------------------- /src/examples/resources/appender_rollingfile.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderRollingFile 19 | log4php.appender.default.layout = LoggerLayoutTTCC 20 | log4php.appender.default.file = target/examples/appender_rollingfile.log 21 | log4php.appender.default.MaxFileSize = 100 22 | log4php.appender.default.MaxBackupIndex = 3 23 | log4php.rootLogger = DEBUG, default 24 | -------------------------------------------------------------------------------- /src/examples/resources/appender_socket.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderSocket 19 | log4php.appender.default.layout = LoggerLayoutSimple 20 | log4php.appender.default.remoteHost = localhost 21 | log4php.appender.default.port = 4242 22 | log4php.appender.default.useXml = true 23 | log4php.appender.default.locationInfo = false 24 | log4php.rootLogger = DEBUG, default 25 | -------------------------------------------------------------------------------- /src/examples/resources/appender_socket_server.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.debug = true 19 | log4php.appender.file = LoggerAppenderFile 20 | log4php.appender.file.file = server.log 21 | log4php.appender.file.layout = LoggerLayoutTTCC 22 | log4php.appender.console = LoggerAppenderEcho 23 | log4php.appender.console.layout = LoggerLayoutSimple 24 | log4php.rootLogger = INFO, file, console 25 | -------------------------------------------------------------------------------- /src/examples/resources/appender_syslog.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderSyslog 19 | log4php.appender.default.layout = LoggerLayoutSimple 20 | log4php.appender.default.ident = log4php-test 21 | log4php.appender.default.facility = USER 22 | log4php.appender.default.option = "PID|CONS|NDELAY" 23 | log4php.rootLogger = DEBUG, default 24 | -------------------------------------------------------------------------------- /src/examples/resources/cache.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutSimple 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/configurator_php.php: -------------------------------------------------------------------------------- 1 | 'ALL', 20 | 'rootLogger' => array( 21 | 'level' => 'INFO', 22 | 'appenders' => array('default'), 23 | ), 24 | 'loggers' => array( 25 | 'dev' => array( 26 | 'level' => 'DEBUG', 27 | 'appenders' => array('default'), 28 | ), 29 | ), 30 | 'appenders' => array( 31 | 'default' => array( 32 | 'class' => 'LoggerAppenderEcho', 33 | 'layout' => array( 34 | 'class' => 'LoggerLayoutPattern', 35 | 'conversionPattern' => "%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n", 36 | ), 37 | ), 38 | ), 39 | ); 40 | -------------------------------------------------------------------------------- /src/examples/resources/configurator_xml.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/examples/resources/filter_denyall.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/examples/resources/filter_levelmatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/examples/resources/filter_levelrange.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/examples/resources/filter_stringmatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/examples/resources/layout_html.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutHtml 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/layout_pattern.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutPattern 20 | log4php.appender.default.layout.ConversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" 21 | log4php.rootLogger = DEBUG, default 22 | -------------------------------------------------------------------------------- /src/examples/resources/layout_simple.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutSimple 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/layout_ttcc.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutTTCC 20 | log4php.appender.default.layout.MicroSecondsPrinting = false 21 | log4php.appender.default.layout.categoryPrefixing = true 22 | log4php.appender.default.layout.dateFormat = "%H:%M" 23 | log4php.rootLogger = DEBUG, default 24 | -------------------------------------------------------------------------------- /src/examples/resources/layout_xml.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutXml 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/mdc.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutPattern 20 | log4php.appender.default.layout.conversionPattern="%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n" 21 | log4php.rootLogger = DEBUG, default 22 | 23 | -------------------------------------------------------------------------------- /src/examples/resources/ndc.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutPattern 20 | log4php.appender.default.layout.conversionPattern="%d{Y-m-d H:i:s} %-5p %c %x: %m in %F at %L%n" 21 | log4php.rootLogger = DEBUG, default 22 | -------------------------------------------------------------------------------- /src/examples/resources/renderer_default.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.appender.default = LoggerAppenderEcho 19 | log4php.appender.default.layout = LoggerLayoutSimple 20 | log4php.rootLogger = DEBUG, default 21 | -------------------------------------------------------------------------------- /src/examples/resources/renderer_map.properties: -------------------------------------------------------------------------------- 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 | ; START SNIPPET: doxia 18 | log4php.renderer.Person = PersonRenderer 19 | 20 | log4php.appender.default = LoggerAppenderEcho 21 | log4php.appender.default.layout = LoggerLayoutSimple 22 | log4php.rootLogger = DEBUG, default 23 | -------------------------------------------------------------------------------- /src/main/php/LoggerConfigurator.php: -------------------------------------------------------------------------------- 1 | getRenderedMessage(); 44 | } 45 | 46 | /** 47 | * Returns the content type output by this layout. 48 | * @return string 49 | */ 50 | public function getContentType() { 51 | return "text/plain"; 52 | } 53 | 54 | /** 55 | * Returns the footer for the layout format. 56 | * @return string 57 | */ 58 | public function getFooter() { 59 | return null; 60 | } 61 | 62 | /** 63 | * Returns the header for the layout format. 64 | * @return string 65 | */ 66 | public function getHeader() { 67 | return null; 68 | } 69 | 70 | /** Triggers a warning for this layout with the given message. */ 71 | protected function warn($message) { 72 | trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/php/LoggerRoot.php: -------------------------------------------------------------------------------- 1 | setLevel($level); 41 | } 42 | 43 | /** 44 | * @return LoggerLevel the level 45 | */ 46 | public function getEffectiveLevel() { 47 | return $this->getLevel(); 48 | } 49 | 50 | /** 51 | * Override level setter to prevent setting the root logger's level to 52 | * null. Root logger must always have a level. 53 | * 54 | * @param LoggerLevel $level 55 | */ 56 | public function setLevel(LoggerLevel $level = null) { 57 | if (isset($level)) { 58 | parent::setLevel($level); 59 | } else { 60 | trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING); 61 | } 62 | } 63 | 64 | /** 65 | * Override parent setter. Root logger cannot have a parent. 66 | * @param Logger $parent 67 | */ 68 | public function setParent(Logger $parent) { 69 | trigger_error("log4php: LoggerRoot cannot have a parent.", E_USER_WARNING); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/php/LoggerThrowableInformation.php: -------------------------------------------------------------------------------- 1 | throwable = $throwable; 42 | } 43 | 44 | /** 45 | * Return source exception 46 | * 47 | * @return Throwable 48 | */ 49 | public function getThrowable() { 50 | return $this->throwable; 51 | } 52 | 53 | /** 54 | * @desc Returns string representation of throwable 55 | * 56 | * @return array 57 | */ 58 | public function getStringRepresentation() { 59 | if (!is_array($this->throwableArray)) { 60 | $renderer = new LoggerRendererException(); 61 | 62 | $this->throwableArray = explode("\n", $renderer->render($this->throwable)); 63 | } 64 | 65 | return $this->throwableArray; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/php/appenders/LoggerAppenderNull.php: -------------------------------------------------------------------------------- 1 | level < WARN mapped to E_USER_NOTICE 28 | * - WARN <= level < ERROR mapped to E_USER_WARNING 29 | * - level >= ERROR mapped to E_USER_ERROR 30 | * 31 | * @version $Revision$ 32 | * @package log4php 33 | * @subpackage appenders 34 | * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 35 | * @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation 36 | */ 37 | class LoggerAppenderPhp extends LoggerAppender { 38 | 39 | public function append(LoggerLoggingEvent $event) { 40 | $level = $event->getLevel(); 41 | if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { 42 | trigger_error($this->layout->format($event), E_USER_ERROR); 43 | } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { 44 | trigger_error($this->layout->format($event), E_USER_WARNING); 45 | } else { 46 | trigger_error($this->layout->format($event), E_USER_NOTICE); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/php/configurators/LoggerConfigurationAdapter.php: -------------------------------------------------------------------------------- 1 | 30 | * An example for this filter: 31 | * 32 | * {@example ../../examples/php/filter_denyall.php 19} 33 | * 34 | *

35 | * The corresponding XML file: 36 | * 37 | * {@example ../../examples/resources/filter_denyall.xml 18} 38 | * 39 | * @version $Revision$ 40 | * @package log4php 41 | * @subpackage filters 42 | * @since 0.3 43 | */ 44 | class LoggerFilterDenyAll extends LoggerFilter { 45 | 46 | /** 47 | * Always returns the integer constant {@link LoggerFilter::DENY} 48 | * regardless of the {@link LoggerLoggingEvent} parameter. 49 | * 50 | * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter. 51 | * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY} 52 | */ 53 | public function decide(LoggerLoggingEvent $event) { 54 | return LoggerFilter::DENY; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/php/helpers/LoggerFormattingInfo.php: -------------------------------------------------------------------------------- 1 | setBoolean('locationInfo', $value); 41 | } 42 | 43 | /** Returns the location information flag. */ 44 | public function getLocationInfo() { 45 | return $this->locationInfo; 46 | } 47 | 48 | public function format(LoggerLoggingEvent $event) { 49 | // If required, initialize the location data 50 | if($this->locationInfo) { 51 | $event->getLocationInformation(); 52 | } 53 | return serialize($event) . PHP_EOL; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/php/layouts/LoggerLayoutSimple.php: -------------------------------------------------------------------------------- 1 | level, followed by " - " and then the message. 26 | * 27 | * For example the following php and properties files 28 | * 29 | * {@example ../../examples/php/layout_simple.php 19}
30 | * 31 | * {@example ../../examples/resources/layout_simple.properties 18}
32 | * 33 | * would result in: 34 | * 35 | * INFO - Hello World! 36 | * 37 | * @version $Revision$ 38 | * @package log4php 39 | * @subpackage layouts 40 | */ 41 | class LoggerLayoutSimple extends LoggerLayout { 42 | /** 43 | * Returns the log statement in a format consisting of the 44 | * level, followed by " - " and then the 45 | * message. For example, 46 | * INFO - "A message" 47 | * 48 | * @param LoggerLoggingEvent $event 49 | * @return string 50 | */ 51 | public function format(LoggerLoggingEvent $event) { 52 | $level = $event->getLevel(); 53 | $message = $event->getRenderedMessage(); 54 | return "$level - $message" . PHP_EOL; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterClass.php: -------------------------------------------------------------------------------- 1 | option) && is_numeric($this->option) && $this->option >= 0) { 41 | $this->length = (integer) $this->option; 42 | } 43 | } 44 | 45 | public function convert(LoggerLoggingEvent $event) { 46 | $name = $event->getLocationInformation()->getClassName(); 47 | 48 | if (!isset($this->cache[$name])) { 49 | 50 | // If length is set return shortened class name 51 | if (isset($this->length)) { 52 | $this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length); 53 | } 54 | 55 | // If no length is specified return the full class name 56 | else { 57 | $this->cache[$name] = $name; 58 | } 59 | } 60 | 61 | return $this->cache[$name]; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterCookie.php: -------------------------------------------------------------------------------- 1 | getLocationInformation()->getFileName(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterLevel.php: -------------------------------------------------------------------------------- 1 | getLevel()->toString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterLine.php: -------------------------------------------------------------------------------- 1 | getLocationInformation()->getLineNumber(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterLiteral.php: -------------------------------------------------------------------------------- 1 | literalValue = $literalValue; 35 | } 36 | 37 | public function convert(LoggerLoggingEvent $event) { 38 | return $this->literalValue; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterLocation.php: -------------------------------------------------------------------------------- 1 | getLocationInformation()->getClassName() . '.' . 35 | $event->getLocationInformation()->getMethodName() . '(' . 36 | $event->getLocationInformation()->getFileName() . ':' . 37 | $event->getLocationInformation()->getLineNumber() . ')'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterLogger.php: -------------------------------------------------------------------------------- 1 | option) && is_numeric($this->option) && $this->option >= 0) { 43 | $this->length = (integer) $this->option; 44 | } 45 | } 46 | 47 | public function convert(LoggerLoggingEvent $event) { 48 | $name = $event->getLoggerName(); 49 | 50 | if (!isset($this->cache[$name])) { 51 | 52 | // If length is set return shortened logger name 53 | if (isset($this->length)) { 54 | $this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length); 55 | } 56 | 57 | // If no length is specified return full logger name 58 | else { 59 | $this->cache[$name] = $name; 60 | } 61 | } 62 | 63 | return $this->cache[$name]; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterMDC.php: -------------------------------------------------------------------------------- 1 | option) && $this->option !== '') { 38 | $this->key = $this->option; 39 | } 40 | } 41 | 42 | public function convert(LoggerLoggingEvent $event) { 43 | if (isset($this->key)) { 44 | return $event->getMDC($this->key); 45 | } else { 46 | $buff = array(); 47 | $map = $event->getMDCMap(); 48 | foreach($map as $key => $value) { 49 | $buff []= "$key=$value"; 50 | } 51 | return implode(', ', $buff); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterMessage.php: -------------------------------------------------------------------------------- 1 | getRenderedMessage(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterMethod.php: -------------------------------------------------------------------------------- 1 | getLocationInformation()->getMethodName(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterNDC.php: -------------------------------------------------------------------------------- 1 | getNDC(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterNewLine.php: -------------------------------------------------------------------------------- 1 | getRelativeTime(); 34 | return number_format($ts, 4); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/php/pattern/LoggerPatternConverterRequest.php: -------------------------------------------------------------------------------- 1 | getThrowableInformation(); 33 | if (isset($info)) { 34 | $ex = $info->getThrowable(); 35 | return (string) $ex . PHP_EOL; 36 | } 37 | return ''; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/php/renderers/LoggerRenderer.php: -------------------------------------------------------------------------------- 1 | input to a string. 32 | * @param mixed $input The entity to render. 33 | * @return string The rendered string. 34 | */ 35 | public function render($input); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/php/renderers/LoggerRendererDefault.php: -------------------------------------------------------------------------------- 1 | print_r. 25 | * 26 | * @package log4php 27 | * @subpackage renderers 28 | * @since 0.3 29 | */ 30 | class LoggerRendererDefault implements LoggerRenderer { 31 | 32 | /** @inheritdoc */ 33 | public function render($input) { 34 | return print_r($input, true); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/php/renderers/LoggerRendererException.php: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | Apache log4php 21 | Engine for searching the Apache log4php web site. 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 43 | 44 | 45 | 47 | 48 | -------------------------------------------------------------------------------- /src/site/resources/images/collapsed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/images/collapsed.gif -------------------------------------------------------------------------------- /src/site/resources/images/expanded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/images/expanded.gif -------------------------------------------------------------------------------- /src/site/resources/images/logos/ls-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/images/logos/ls-logo.jpg -------------------------------------------------------------------------------- /src/site/resources/images/logos/maven-feather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/images/logos/maven-feather.png -------------------------------------------------------------------------------- /src/site/resources/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /src/site/resources/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/logging-log4php/aea69f3ddfe4856c30a8db077a02111a6ec5a3e1/src/site/resources/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /src/test/config/phpunit_to_surefire.xslt: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | . 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/php/LoggerExceptionTest.php: -------------------------------------------------------------------------------- 1 | getMessage()); 38 | throw $e; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/php/LoggerFilterTest.php: -------------------------------------------------------------------------------- 1 | activateOptions(); 36 | $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage"); 37 | $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage"); 38 | $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage"); 39 | 40 | $result = $filter->decide($eventError); 41 | self::assertEquals($result, LoggerFilter::NEUTRAL); 42 | 43 | $result = $filter->decide($eventDebug); 44 | self::assertEquals($result, LoggerFilter::NEUTRAL); 45 | 46 | $result = $filter->decide($eventWarn); 47 | self::assertEquals($result, LoggerFilter::NEUTRAL); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/php/LoggerIdGenerator.php: -------------------------------------------------------------------------------- 1 | requestId == null) { 17 | $dateTime = new DateTime(); 18 | $this->requestId = $dateTime->getTimestamp() . rand(1000, 9999); 19 | } 20 | return $this->requestId; 21 | } 22 | 23 | public function getSeq() { 24 | return $this->sequence++; 25 | } 26 | 27 | public static function me() { 28 | return self::getInstance(); 29 | } 30 | 31 | final public static function getInstance() { 32 | 33 | if(!isset(self::$instance)) { 34 | self::$instance = new self; 35 | } 36 | 37 | return self::$instance; 38 | } 39 | 40 | final private function __clone() {/* do not clone me */ 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/php/LoggerRootTest.php: -------------------------------------------------------------------------------- 1 | getLevel()); 33 | self::assertSame(LoggerLevel::getLevelAll(), $root->getEffectiveLevel()); 34 | self::assertSame('root', $root->getName()); 35 | self::assertNull($root->getParent()); 36 | } 37 | 38 | /** 39 | * @expectedException PHPUnit_Framework_Error 40 | * @expectedExceptionMessage log4php: LoggerRoot cannot have a parent. 41 | */ 42 | public function testSetParentWarning() { 43 | $root = new LoggerRoot(); 44 | $logger = new Logger('test'); 45 | $root->setParent($logger); 46 | } 47 | 48 | public function testSetParentResult() { 49 | $root = new LoggerRoot(); 50 | $logger = new Logger('test'); 51 | @$root->setParent($logger); 52 | self::assertNull($root->getParent()); 53 | } 54 | 55 | /** 56 | * @expectedException PHPUnit_Framework_Error 57 | * @expectedExceptionMessage log4php: Cannot set LoggerRoot level to null. 58 | */ 59 | public function testNullLevelWarning() { 60 | $root = new LoggerRoot(); 61 | $root->setLevel(null); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/php/README: -------------------------------------------------------------------------------- 1 | All tests can be run from the root of the package by running: 2 | $ phpunit 3 | 4 | Tests classes are divided into groups which can be run individually: 5 | $ phpunit --group main 6 | $ phpunit --group appenders 7 | $ phpunit --group configurators 8 | $ phpunit --group filters 9 | $ phpunit --group helpers 10 | $ phpunit --group layouts 11 | $ phpunit --group renderers 12 | 13 | Individual test classes can be run using e.g.: 14 | $ phpunit src/test/php/appenders/LoggerAppenderSocketTest.php 15 | 16 | Do not use relative file paths in the tests. Absoulte paths may be constructed 17 | using snippets like: 18 | * dirname(__FILE__) . '/../path/to/file' 19 | * PHPUNIT_TEMP_DIR . '/../path/to/file' 20 | -------------------------------------------------------------------------------- /src/test/php/appenders/LoggerAppenderMailTest.php: -------------------------------------------------------------------------------- 1 | requiresLayout()); 34 | } 35 | 36 | public function testMail() { 37 | $appender = new LoggerAppenderMail("myname "); 38 | 39 | $layout = new LoggerLayoutSimple(); 40 | $appender->setLayout($layout); 41 | $appender->setDry(true); 42 | $appender->setTo('test@example.com'); 43 | $appender->setFrom('Testsender'); 44 | 45 | $appender->activateOptions(); 46 | $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage"); 47 | $event2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage2"); 48 | 49 | ob_start(); 50 | $appender->append($event); 51 | $appender->append($event2); 52 | $appender->close(); 53 | $v = ob_get_contents(); 54 | ob_end_clean(); 55 | 56 | $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with content: ERROR - testmessage".PHP_EOL."ERROR - testmessage2".PHP_EOL; 57 | self::assertEquals($e, $v); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/test/php/appenders/LoggerAppenderNullTest.php: -------------------------------------------------------------------------------- 1 | activateOptions(); 39 | $appender->append($event); 40 | $appender->close(); 41 | } 42 | 43 | public function testRequiresLayout() { 44 | $appender = new LoggerAppenderNull(); 45 | self::assertFalse($appender->requiresLayout()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/php/bootstrap.php: -------------------------------------------------------------------------------- 1 | parse(); 39 | 40 | // $actual = ''; 41 | // $c->format($actual, $event); 42 | // self::assertEquals($expected, $actual); 43 | 44 | } 45 | 46 | public function testClassname() { 47 | // $event = new LoggerLoggingEvent("MyClass", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage"); 48 | // $expected = 'MyClass'; 49 | // $patternParser = new LoggerPatternParser("%C"); 50 | // $c = $patternParser->parse(); 51 | // $actual = ''; 52 | // $c->format($actual, $event); 53 | // self::assertEquals($expected, $actual); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/php/layouts/LoggerLayoutPatternTest.php: -------------------------------------------------------------------------------- 1 | pattern); 37 | Logger::configure($config); 38 | 39 | ob_start(); 40 | $log = Logger::getLogger('LoggerTest'); 41 | $log->error("my message"); $line = __LINE__; 42 | $actual = ob_get_contents(); 43 | ob_end_clean(); 44 | 45 | $file = __FILE__; 46 | $class = __CLASS__; 47 | $method = __FUNCTION__; 48 | 49 | $expected = "ERROR LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL; 50 | self::assertSame($expected, $actual); 51 | 52 | Logger::resetConfiguration(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/php/layouts/LoggerLayoutSimpleTest.php: -------------------------------------------------------------------------------- 1 | format($event); 36 | $expected = "ERROR - testmessage" . PHP_EOL; 37 | self::assertEquals($expected, $actual); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini: -------------------------------------------------------------------------------- 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 | log4php.rootLogger = DEBUG, default 19 | 20 | log4php.appender.default = LoggerAppenderEcho 21 | 22 | # invalid appender line should trigger warning 23 | log4php.appender.default.layout.param.bla = LoggerLayoutTTCC 24 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini: -------------------------------------------------------------------------------- 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 | log4php.rootLogger = DEBUG, default 19 | 20 | log4php.appender.default = LoggerAppenderEcho 21 | 22 | # invalid appender line should trigger warning 23 | log4php.appender.default.not-layout.param = LoggerLayoutTTCC 24 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/ini/config_invalid_syntax.ini: -------------------------------------------------------------------------------- 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 | not a valid ini file () 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/ini/config_valid.ini: -------------------------------------------------------------------------------- 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 | log4php.rootLogger = DEBUG, default 19 | 20 | log4php.appender.default = LoggerAppenderEcho 21 | log4php.appender.default.layout = LoggerLayoutTTCC 22 | 23 | log4php.appender.file = LoggerAppenderDailyFile 24 | log4php.appender.file.layout = LoggerLayoutPattern 25 | log4php.appender.file.layout.conversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" 26 | log4php.appender.file.datePattern = Ymd 27 | log4php.appender.file.file = target/examples/daily_%s.log 28 | log4php.appender.file.threshold = warn 29 | 30 | log4php.logger.foo = warn, default 31 | 32 | log4php.logger.foo.bar = debug, file 33 | log4php.additivity.foo.bar = "true" 34 | 35 | log4php.logger.foo.bar.baz = trace, default, file 36 | log4php.additivity.foo.bar.baz = "false" 37 | 38 | log4php.renderer.Fruit = FruitRenderer 39 | log4php.renderer.Beer = BeerRenderer 40 | 41 | log4php.threshold = debug 42 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/ini/values.ini: -------------------------------------------------------------------------------- 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 | unquoted_true = true 19 | unquoted_false = false 20 | unquoted_yes = true 21 | unquoted_no = false 22 | quoted_true = "true" 23 | quoted_false = "false" 24 | unquoted_one = 1 25 | unquoted_zero = 0 -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/php/config_empty.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/php/config_invalid_syntax.php: -------------------------------------------------------------------------------- 1 | array( 28 | 'level' => 'info', 29 | 'appenders' => array('default') 30 | ), 31 | 'appenders' => array( 32 | 'default' => array( 33 | 'class' => 'LoggerAppenderEcho', 34 | 'layout' => array( 35 | 'class' => 'LoggerLayoutSimple' 36 | ) 37 | ) 38 | ) 39 | 40 | // Invalid file - no closing brace. 41 | 42 | ?> -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/php/config_not_an_array.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/php/config_valid.php: -------------------------------------------------------------------------------- 1 | array( 28 | 'level' => 'info', 29 | 'appenders' => array('default') 30 | ), 31 | 'appenders' => array( 32 | 'default' => array( 33 | 'class' => 'LoggerAppenderEcho', 34 | 'layout' => array( 35 | 'class' => 'LoggerLayoutSimple' 36 | ) 37 | ) 38 | ) 39 | ) 40 | ; 41 | 42 | ?> -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/xml/config_duplicate_logger.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/xml/config_duplicate_renderer.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/resources/configs/adapters/xml/config_invalid_syntax.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_invalid_appender_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_invalid_filter_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_invalid_filter_parameters.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_invalid_layout_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_no_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_no_layout_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_not_existing_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_not_existing_filter_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/appenders/config_not_existing_layout_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/config.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | -------------------------------------------------------------------------------- /src/test/resources/configs/loggers/config_invalid_additivity.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/resources/configs/loggers/config_not_existing_appenders.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/test/resources/configs/renderers/config_default_renderer.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/test/resources/configs/renderers/config_invalid_rendering_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/resources/configs/renderers/config_no_rendered_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/test/resources/configs/renderers/config_no_rendering_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/test/resources/configs/renderers/config_not_existing_rendering_class.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | --------------------------------------------------------------------------------