[Feature request] Separated logs for the virtual hosts


  • | 1090 points

    Dear @leokhoa

    The auto-created virtual hosts feature rocks! I like it so much.

    I know the PHP display_errors is turned on by default but I would prefer turning it off and using logs to track errors and requests. And I realize that Laragon does not have the separated logs for the virtual hosts by default.

    Please add this features. You can add it to the directory "logs" in the main dir.

    Thanks in advance!


  • administrators
    | 48370 points

    @vienmq : You can do it with current version.
    Laragon is "batteries included, but extendable". It means Laragon does almost magics for you but you can add your own magics :)

    Laragon does not only auto create virtual hosts, it also allow you define your own VirtualHost template.
    In your case, you can follow these steps:

    1. Delete all auto generated virtual hosts: Menu -> Apache -> <VirtualHost> -> Delete all [auto]
    2. Open usr folder (it is where you store your own preferences): Menu -> Laragon -> dir: usr
    3. Go to usr/tpl folder, delete VirtualHost.tpl (this template file is auto created when SSL is enabled or not)
    4. Edit VirtualHost.manifest if you don't use SSL (otherwise, edit VirtualHost.SSL.manifest)
    5. Add these 2 lines above </VirtualHost>:
        CustomLog logs/<<HOSTNAME>>-access.log combined
        ErrorLog  logs/<<HOSTNAME>>-error.log
    

    You got it.

    Notes:

    • With the above configuration, logs will be stored in {APACHE_DIR}/logs, you can change to absolute paths if you want.
    • Laragon respects all changes in the usr folder. When reinstalling Laragon, all things in the folder will keep intact.
    • The VirtualHost.manifest will look like this:
    <VirtualHost *:<<PORT>>> 
        DocumentRoot "<<PROJECT_DIR>>"
        ServerName <<HOSTNAME>>
        ServerAlias *.<<HOSTNAME>>
        <Directory "<<PROJECT_DIR>>">
            AllowOverride All
            Require all granted
        </Directory>
    
        CustomLog logs/<<HOSTNAME>>-access.log combined
        ErrorLog  logs/<<HOSTNAME>>-error.log
    </VirtualHost>
    
    # If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled
    

  • | 1090 points

    Thank you so much! Very detailed explanation. I think you should clone your post to a new one in the Tutorial topic. :)


  • administrators
    | 48370 points

    I will. Thanks :)


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.