{
    "mode": "perldoc",
    "parameter": "Log::Log4perl::Config",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Log%3A%3ALog4perl%3A%3AConfig/json",
    "generated": "2026-06-10T16:29:55Z",
    "sections": {
        "NAME": {
            "content": "Log::Log4perl::Config - Log4perl configuration file syntax\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "In \"Log::Log4perl\", configuration files are used to describe how the system's loggers ought to\nbehave.\n\nThe format is the same as the one as used for \"log4j\", just with a few perl-specific extensions,\nlike enabling the \"Bar::Twix\" syntax instead of insisting on the Java-specific \"Bar.Twix\".\n\nComment lines and blank lines (all whitespace or empty) are ignored.\n\nComment lines may start with arbitrary whitespace followed by one of:\n\n# - Common comment delimiter\n! - Java .properties file comment delimiter accepted by log4j\n; - Common .ini file comment delimiter\n\nComments at the end of a line are not supported. So if you write\n\nlog4perl.appender.A1.filename=error.log #in current dir\n\nyou will find your messages in a file called \"error.log #in current dir\".\n\nAlso, blanks between syntactical entities are ignored, it doesn't matter if you write\n\nlog4perl.logger.Bar.Twix=WARN,Screen\n\nor\n\nlog4perl.logger.Bar.Twix = WARN, Screen\n\n\"Log::Log4perl\" will strip the blanks while parsing your input.\n\nAssignments need to be on a single line. However, you can break the line if you want to by using\na continuation character at the end of the line. Instead of writing\n\nlog4perl.appender.A1.layout=Log::Log4perl::Layout::SimpleLayout\n\nyou can break the line at any point by putting a backslash at the very (!) end of the line to be\ncontinued:\n\nlog4perl.appender.A1.layout=\\\nLog::Log4perl::Layout::SimpleLayout\n\nWatch out for trailing blanks after the backslash, which would prevent the line from being\nproperly concatenated.\n",
            "subsections": [
                {
                    "name": "Loggers",
                    "content": "Loggers are addressed by category:\n\nlog4perl.logger.Bar.Twix      = WARN, Screen\n\nThis sets all loggers under the \"Bar::Twix\" hierarchy on priority \"WARN\" and attaches a\nlater-to-be-defined \"Screen\" appender to them. Settings for the root appender (which doesn't\nhave a name) can be accomplished by simply omitting the name:\n\nlog4perl.logger = FATAL, Database, Mailer\n\nThis sets the root appender's level to \"FATAL\" and also attaches the later-to-be-defined\nappenders \"Database\" and \"Mailer\" to it. Alternatively, the root logger can be addressed as\n\"rootLogger\":\n\nlog4perl.rootLogger = FATAL, Database, Mailer\n\nThe additivity flag of a logger is set or cleared via the \"additivity\" keyword:\n\nlog4perl.additivity.Bar.Twix = 0|1\n\n(Note the reversed order of keyword and logger name, resulting from the dilemma that a logger\nname could end in \".additivity\" according to the log4j documentation).\n"
                },
                {
                    "name": "Appenders and Layouts",
                    "content": "Appender names used in Log4perl configuration file lines need to be resolved later on, in order\nto define the appender's properties and its layout. To specify properties of an appender, just\nuse the \"appender\" keyword after the \"log4perl\" intro and the appender's name:\n\n# The Bar::Twix logger and its appender\nlog4perl.logger.Bar.Twix = DEBUG, A1\nlog4perl.appender.A1=Log::Log4perl::Appender::File\nlog4perl.appender.A1.filename=test.log\nlog4perl.appender.A1.mode=append\nlog4perl.appender.A1.layout=Log::Log4perl::Layout::SimpleLayout\n\nThis sets a priority of \"DEBUG\" for loggers in the \"Bar::Twix\" hierarchy and assigns the \"A1\"\nappender to it, which is later on resolved to be an appender of type\n\"Log::Log4perl::Appender::File\", simply appending to a log file. According to the\n\"Log::Log4perl::Appender::File\" manpage, the \"filename\" parameter specifies the name of the log\nfile and the \"mode\" parameter can be set to \"append\" or \"write\" (the former will append to the\nlogfile if one with the specified name already exists while the latter would clobber and\noverwrite it).\n\nThe order of the entries in the configuration file is not important, \"Log::Log4perl\" will read\nin the entire file first and try to make sense of the lines after it knows the entire context.\n\nYou can very well define all loggers first and then their appenders (you could even define your\nappenders first and then your loggers, but let's not go there):\n\nlog4perl.logger.Bar.Twix = DEBUG, A1\nlog4perl.logger.Bar.Snickers = FATAL, A2\n\nlog4perl.appender.A1=Log::Log4perl::Appender::File\nlog4perl.appender.A1.filename=test.log\nlog4perl.appender.A1.mode=append\nlog4perl.appender.A1.layout=Log::Log4perl::Layout::SimpleLayout\n\nlog4perl.appender.A2=Log::Log4perl::Appender::Screen\nlog4perl.appender.A2.stderr=0\nlog4perl.appender.A2.layout=Log::Log4perl::Layout::PatternLayout\nlog4perl.appender.A2.layout.ConversionPattern = %d %m %n\n\nNote that you have to specify the full path to the layout class and that \"ConversionPattern\" is\nthe keyword to specify the printf-style formatting instructions.\n"
                }
            ]
        },
        "Configuration File Cookbook": {
            "content": "Here's some examples of often-used Log4perl configuration files:\n",
            "subsections": [
                {
                    "name": "Append to STDERR",
                    "content": "log4perl.category.Bar.Twix      = WARN, Screen\nlog4perl.appender.Screen        = Log::Log4perl::Appender::Screen\nlog4perl.appender.Screen.layout = \\\nLog::Log4perl::Layout::PatternLayout\nlog4perl.appender.Screen.layout.ConversionPattern = %d %m %n\n"
                },
                {
                    "name": "Append to STDOUT",
                    "content": "log4perl.category.Bar.Twix      = WARN, Screen\nlog4perl.appender.Screen        = Log::Log4perl::Appender::Screen\nlog4perl.appender.Screen.stderr = 0\nlog4perl.appender.Screen.layout = \\\nLog::Log4perl::Layout::PatternLayout\nlog4perl.appender.Screen.layout.ConversionPattern = %d %m %n\n"
                },
                {
                    "name": "Append to a log file",
                    "content": "log4perl.logger.Bar.Twix = DEBUG, A1\nlog4perl.appender.A1=Log::Log4perl::Appender::File\nlog4perl.appender.A1.filename=test.log\nlog4perl.appender.A1.mode=append\nlog4perl.appender.A1.layout = \\\nLog::Log4perl::Layout::PatternLayout\nlog4perl.appender.A1.layout.ConversionPattern = %d %m %n\n\nNote that you could even leave out\n\nlog4perl.appender.A1.mode=append\n\nand still have the logger append to the logfile by default, although the\n\"Log::Log4perl::Appender::File\" module does exactly the opposite. This is due to some nasty\ntrickery \"Log::Log4perl\" performs behind the scenes to make sure that beginner's CGI\napplications don't clobber the log file every time they're called.\n"
                },
                {
                    "name": "Write a log file from scratch",
                    "content": "If you loathe the Log::Log4perl's append-by-default strategy, you can certainly override it:\n\nlog4perl.logger.Bar.Twix = DEBUG, A1\nlog4perl.appender.A1=Log::Log4perl::Appender::File\nlog4perl.appender.A1.filename=test.log\nlog4perl.appender.A1.mode=write\nlog4perl.appender.A1.layout=Log::Log4perl::Layout::SimpleLayout\n\n\"write\" is the \"mode\" that has \"Log::Log4perl::Appender::File\" explicitly clobber the log file\nif it exists.\n"
                },
                {
                    "name": "Configuration files encoded in utf-8",
                    "content": "If your configuration file is encoded in utf-8 (which matters if you e.g. specify utf8-encoded\nappender filenames in it), then you need to tell Log4perl before running init():\n\nuse Log::Log4perl::Config;\nLog::Log4perl::Config->utf( 1 );\n\nLog::Log4perl->init( ... );\n\nThis makes sure Log4perl interprets utf8-encoded config files correctly. This setting might\nbecome the default at some point.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "Log::Log4perl::Config::PropertyConfigurator\n\nLog::Log4perl::Config::DOMConfigurator\n\nLog::Log4perl::Config::LDAPConfigurator (coming soon!)\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyright 2002-2013 by Mike Schilli <m@perlmeister.com> and Kevin Goess <cpan@goess.org>.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Please contribute patches to the project on Github:\n\nhttp://github.com/mschilli/log4perl\n\nSend bug reports or requests for enhancements to the authors via our\n\nMAILING LIST (questions, bug reports, suggestions/patches): log4perl-devel@lists.sourceforge.net\n\nAuthors (please contact them via the list above, not directly): Mike Schilli\n<m@perlmeister.com>, Kevin Goess <cpan@goess.org>\n\nContributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp,\nHutton Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon,\nCarl Franks, Dennis Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier David Hull,\nRobert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter, Brett Rann, Peter Rabbitson, Erik\nSelberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang.\n",
            "subsections": []
        }
    },
    "summary": "Log::Log4perl::Config - Log4perl configuration file syntax",
    "flags": [],
    "examples": [],
    "see_also": []
}