{
    "mode": "perldoc",
    "parameter": "Log::Log4perl::Catalyst",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Log%3A%3ALog4perl%3A%3ACatalyst/json",
    "generated": "2026-06-11T15:27:58Z",
    "synopsis": "In your main Catalyst application module:\nuse Log::Log4perl::Catalyst;\n# Either make Log4perl act like the Catalyst default logger:\nPACKAGE->log(Log::Log4perl::Catalyst->new());\n# or use a Log4perl configuration file, utilizing the full\n# functionality of Log4perl\nPACKAGE->log(Log::Log4perl::Catalyst->new('l4p.conf'));\n... and then sprinkle logging statements all over any code executed by Catalyst:\n$c->log->debug(\"This is using log4perl!\");",
    "sections": {
        "NAME": {
            "content": "Log::Log4perl::Catalyst - Log::Log4perl Catalyst Module\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "In your main Catalyst application module:\n\nuse Log::Log4perl::Catalyst;\n\n# Either make Log4perl act like the Catalyst default logger:\nPACKAGE->log(Log::Log4perl::Catalyst->new());\n\n# or use a Log4perl configuration file, utilizing the full\n# functionality of Log4perl\nPACKAGE->log(Log::Log4perl::Catalyst->new('l4p.conf'));\n\n... and then sprinkle logging statements all over any code executed by Catalyst:\n\n$c->log->debug(\"This is using log4perl!\");\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides Log4perl functions to Catalyst applications. It was inspired by\nCatalyst::Log::Log4perl on CPAN, but has been completely rewritten and uses a different approach\nto unite Catalyst and Log4perl.\n\nLog4perl provides loggers, usually associated with the current package, which can then be\nremote-controlled by a central configuration. This means that if you have a controller function\nlike\n\npackage MyApp::Controller::User;\n\nsub add : Chained('base'): PathPart('add'): Args(0) {\nmy ( $self, $c ) = @;\n\n$c->log->info(\"Adding a user\");\n# ...\n}\n\nLevel-based control is available via the following methods:\n\n$c->log->debug(\"Reading configuration\");\n$c->log->info(\"Adding a user\");\n$c->log->warn(\"Can't read configuration ($!)\");\n$c->log->error(\"Can't add user \", $user);\n$c->log->fatal(\"Database down, aborting request\");\n\nBut that's not all, Log4perl is much more powerful.\n\nThe logging statement can be suppressed or activated based on a Log4perl file that looks like\n\n# All MyApp loggers opened up for DEBUG and above\nlog4perl.logger.MyApp = DEBUG, Screen\n# ...\n\nor\n\n# All loggers block messages below INFO\nlog4perl.logger=INFO, Screen\n# ...\n\nrespectively. See the Log4perl manpage on how to perform fine-grained log-level and location\nfiltering, and how to forward messages not only to the screen or to log files, but also to\ndatabases, email appenders, and much more.\n\nAlso, you can change the message layout. For example if you want to know where a particular\nstatement was logged, turn on file names and line numbers:\n\n# Log4perl configuration file\n# ...\nlog4perl.appender.Screen.layout.ConversionPattern = \\\n%F{1}-%L: %p %m%n\n\nMessages will then look like\n\nMyApp.pm-1869: INFO Saving user profile for user \"wonko\"\n\nOr want to log a request's IP address with every log statement? No problem with Log4perl, just\ncall\n\nLog::Log4perl::MDC->put( \"ip\", $c->req->address() );\n\nat the beginning of the request cycle and use\n\n# Log4perl configuration file\n# ...\nlog4perl.appender.Screen.layout.ConversionPattern = \\\n[%d]-%X{ip} %F{1}-%L: %p %m%n\n\nas a Log4perl layout. Messages will look like\n\n[2010/02/22 23:25:55]-123.122.108.10 MyApp.pm-1953: INFO Reading profile for user \"wonko\"\n\nAgain, check the Log4perl manual page, there's a plethora of configuration options.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "new",
                    "content": "If called without parameters, new() initializes Log4perl in a way so that messages are\nlogged similarly to Catalyst's default logging mechanism. If you provide a configuration,\neither the name of a configuration file or a reference to a scalar string containing the\nconfiguration, it will call Log4perl with these parameters.\n\nThe second (optional) parameter is a list of key/value pairs:\n\n'autoflush'   =>  1   # Log without buffering ('abort' not supported)\n'watchdelay' => 30   # If set, use L<Log::Log4perl>'s initandwatch\n\nflush()\nFlushes the cache.\n"
                },
                {
                    "name": "abort",
                    "content": "Clears the logging system's internal buffers without logging anything.\n"
                },
                {
                    "name": "Using :easy Macros with Catalyst",
                    "content": "If you're tired of typing\n\n$c->log->debug(\"...\");\n\nand would prefer to use Log4perl's convenient :easy mode macros like\n\nDEBUG \"...\";\n\nthen just pull those macros in via Log::Log4perl's :easy mode and start cranking:\n\nuse Log::Log4perl qw(:easy);\n\n# ... use macros later on\nsub base :Chained('/') :PathPart('apples') :CaptureArgs(0) {\nmy ( $self, $c ) = @;\n\nDEBUG \"Handling apples\";\n}\n\nNote the difference between Log4perl's initialization in Catalyst, which uses the\nCatalyst-specific Log::Log4perl::Catalyst module (top of this page), and making use of\nLog4perl's loggers with the standard Log::Log4perl loggers and macros. While initialization\nrequires Log4perl to perform dark magic to conform to Catalyst's different logging strategy,\nobtaining Log4perl's logger objects or calling its macros are unchanged.\n\nInstead of using Catalyst's way of referencing the \"context\" object $c to obtain logger\nreferences via its log() method, you can just as well use Log4perl's getlogger() or macros to\naccess Log4perl's logger singletons. The result is the same.\n"
                }
            ]
        },
        "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::Catalyst - Log::Log4perl Catalyst Module",
    "flags": [],
    "examples": [],
    "see_also": []
}