logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Output multiple logs in different formats
Author
navillus



Joined: 25 Apr 2024
Posts: 2

PostPosted: Fri 26 Apr '24 20:51    Post subject: Output multiple logs in different formats Reply with quote

I inherited an Apache system that uses a custom log format that analyzers don't understand. Can Apache also output a second log in a standard format?

Thanks,
Michael
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 348
Location: UK

PostPosted: Fri 26 Apr '24 21:55    Post subject: Reply with quote

Yes it can.

The LogFormat directive defines the details to be saved in a log file. The default parameter sets are called 'combined' and 'common', and are defined in the standard httpd.conf file. These formats should be accepted by most log file analyzers,

Additional LogFormat entry sets, such as 'custom', can be used to save alternative parameters in log files. Once defined, the CustomLog directive can be used to create log files based on a given format, e.g.
Code:
CustomLog "logs/access.log" combined
# or
CustomLog "logs/access.log" common

So assuming you've got a 'custom' format at the moment, all you need to do is add another CustomLog directive specifying a new log file, with the 'combined' or 'common' format.

See https://httpd.apache.org/docs/current/mod/mod_log_config.html for details.
Back to top
navillus



Joined: 25 Apr 2024
Posts: 2

PostPosted: Mon 29 Apr '24 14:21    Post subject: Reply with quote

Thank you tangent!
Back to top
Stray78



Joined: 15 Apr 2024
Posts: 23
Location: USA

PostPosted: Wed 01 May '24 2:41    Post subject: Reply with quote

you can also not log specific files also.

<IfModule log_config_module>
#
# Don't log these files!
#
SetEnvIf Request_URI \.jpg$ dontlog
SetEnvIf Request_URI \.js$ dontlog
SetEnvIf Request_URI \.css$ dontlog
SetEnvIf Request_URI \.png$ dontlog
SetEnvIf Request_URI \.gif$ dontlog
SetEnvIf Request_URI \.ico$ dontlog
#SetEnvIf Request_URI \.php$ dontlog
#SetEnvIf Request_URI \.htm$ dontlog
#SetEnvIf Request_URI \.html$ dontlog
SetEnvIf Request_URI \.ttf$ dontlog
SetEnvIf Request_URI \.woff2$ dontlog
#SetEnvIfNoCase Request_URI ^woff2$ dontlog
SetEnvIf Request_URI "fontawesome-webfont" dontlog
SetEnvIf Request_URI \.map$ dontlog
SetEnvIf Request_URI \.webp$ dontlog
SetEnvIf Request_URI "^/forms/captcha(.*)$" dontlog

# Speedtest log block #
SetEnvIf Request_URI "/upload" dontlog
SetEnvIf Request_URI "/downloading" dontlog


LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%v | %h | %t \"%r\" %>s %b %T" common_virtualhost

</IfModule>

Set the environmental variables above, then use them in your vhost section.

CustomLog "D:/logs/Apache/HTTPS/Secured.log" "combined" env=!dontlog

Smile
Back to top


Reply to topic   Topic: Output multiple logs in different formats View previous topic :: View next topic
Post new topic   Forum Index -> Apache