Net::Se...Log4perl(3)

πŸ’… Net::Se...Log4perl(3) β€” like, the Net::Server logger that speaks Log4perl, bestie

okay so this is a page from the User Contributed Perl Documentation corner of the world, and it's literally all about Net::Server::Log::Log::Log4perl. Yes, the name has "Log" three times. No, that's not a typo. We don't make the rules, we just slay in them. πŸŽ€


✨ NAME ✨

Net::Server::Log::Log::Log4perl β€” log via Log4perl. That's it, that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

So first you inherit from a personality, like:

use base qw(Net::Server::PreFork);

and then you run it and hand it the log4perl keys:

__PACKAGE__->run(
    log_file => 'Log::Log4perl',
    log4perl_conf => '/path/to/my/log4perl.conf',
    log4perl_logger => 'myapp',
);

and boom, you're logging through Log4perl. periodt. ✨


πŸ’– DESCRIPTION πŸ’–

This module gives the Net::Server system Log::Log4perl-style logging. That's the entire description, it's short and iconic and I respect it. πŸ‘‘


πŸŽ€ CONFIGURATION πŸŽ€

🌈 log_file

To start using Log4perl logging, literally just set the Net::Server config parameter log_file to "Log::Log4perl".

If you use that magic name "Log::Log4perl", all your logging gets sent to the Log4perl system. And if you do it that way, you can also define log4perl_conf, log4perl_poll, and log4perl_logger. iykyk πŸ’…

πŸ“ log4perl_conf

Only available when log_file is equal to "Log::Log4perl". This is the filename of the log4perl configuration file β€” peep Log::Log4perl for the details.

⚠️ If this is not set, it will die on startup. If the file is not readable, it will die. No cap, it does not play about that config file. 😭

🧚 log4perl_poll

If you set this to a value, it'll initialize with Log::Log4perl::init_and_watch using that polling value. Cute.

It can also be the string "HUP" β€” which means re-read log4perl_conf whenever a HUP signal comes in. πŸ“‘

If you set it to 0, no polling is done at all. Slay. See Log::Log4perl for more details.

πŸ¦‹ log4perl_logger

This is the facility name. It defaults to "Net::Server". Simple, iconic, main character energy. πŸ’œ


πŸ‘‘ DEFAULT ARGUMENTS FOR Net::Server πŸ‘‘

These arguments are available in the default Net::Server or Net::Server::Single modules. (Other personalities may use additional parameters and may optionally not use parameters from the base class.)

Heads up bestie, these ones live under the header ## log4perl parameters (if log_file eq Log::Log4perl):

  • log4perl_conf β€” value: "filename", default: will die if not set πŸ’€
  • log4perl_poll β€” value: number or HUP, default: 0 (no polling)
  • log4perl_logger β€” value: "name", default: "Net::Server"

⭐ METHODS ⭐

πŸ’« initialize

This method gets called during the initilize_logging method of Net::Server (yes, that's spelled exactly like that in the original, we keep it, we don't touch it 🫢).

It returns a single code ref that gets stored under the log_function property of the Net::Server object. That code ref takes log_level and message as arguments and calls the initialized log4perl system. It's giving very elegant, very put-together. ✨


πŸ”₯ LICENCE πŸ”₯

Distributed under the same terms as Net::Server. πŸ’–


and that's the whole page, bestie β€” this was Net::Se...Log4perl(3) from the perl v5.42.0 era, dated 2023-03-15. go forth and log responsibly πŸŒˆπŸ’œ

πŸ“¦ where this page comes from