11 Replies Latest reply: Mar 20, 2012 5:39 AM by Kabir Khan RSS

Add access-log via jboss-cli ?

Gonne Martens Novice

Hi,

I have configured the access-log for the subsystem web (JBoss 7.1.0.Final) directly in the standalone.xml, but I did not get it configured by CLI.

Any hints?

 

Regards,

Gonne

 

[standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host:read-resource(recursive=true)
{
    "outcome" => "success",
    "result" => {
        "alias" => [
            "localhost",
            "example.com"
        ],
        "default-web-module" => "ROOT.war",
        "enable-welcome-root" => true,
        "rewrite" => undefined,
        "sso" => undefined,
        "access-log" => {"configuration" => {"directory" => {"configuration" => {"relative-to" => "jboss.server.log.dir"}}}}
    }
}

 

  • 1. Re: Add access-log via jboss-cli ?
    Gonne Martens Novice

    Where are the CLI experts?

  • 2. Re: Add access-log via jboss-cli ?
    jaikiran pai Master

    Sorry I don't understand the question. You posted the read resource output which shows the access-log configuration but you also mention that you couldn't configure it via CLI. What error are you runing into and what command are you using?

  • 3. Re: Add access-log via jboss-cli ?
    Gonne Martens Novice

    Sorry for my unclear question.

    I have managed to activate access-log by editing standalone.xml:

     

    <subsystem xmlns="urn:jboss:domain:web:1.1" native="false" default-virtual-server="default-host">
        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
        <virtual-server name="default-host" enable-welcome-root="true">
            <alias name="localhost"/>
            <alias name="example.com"/>
            <access-log>
                <directory relative-to="jboss.server.log.dir"/>
            </access-log>
        </virtual-server>
    </subsystem>
    

     

     

    But I want to configure it with a CLI command to build a configuration script with my configuration changes. I had no success with my tries to build  the correct syntax.

     

    Kind regards,

    Gonne

  • 4. Re: Add access-log via jboss-cli ?
    alexh_97 Newbie

    This is a very good question - I'm in the same boat.  I can get to what looks like an appropriate subsystem:

     

    [standalone@localhost:9999 /] cd /subsystem=web/virtual-server=default-host

    [standalone@localhost:9999 virtual-server=default-host] ls

    access-log                          rewrite

    sso                                 alias=["localhost","example.com"]

    default-web-module=ROOT.war         enable-welcome-root=true

     

    and even

     

    [standalone@localhost:9999 virtual-server=default-host] cd access-log

    [standalone@localhost:9999 access-log] pwd

    /subsystem=web/virtual-server=default-host/access-log

     

     

    but it's unclear what one can do from here.  Command help is not "helpful":

     

    [standalone@localhost:9999 access-log] help --commands

    Commands available in the current context:

    batch             cd                clear             command

    connect           data-source       deploy            deployment-info

    help              history           ls                pwd

    quit              read-attribute    read-operation    undeploy

    version           xa-data-source

    To read a description of a specific command execute 'command_name --help'.

  • 5. Re: Add access-log via jboss-cli ?
    Kabir Khan Master

    alexh_97 wrote:

     

    This is a very good question - I'm in the same boat.  I can get to what looks like an appropriate subsystem:

     

    [standalone@localhost:9999 /] cd /subsystem=web/virtual-server=default-host

    [standalone@localhost:9999 virtual-server=default-host] ls

    access-log                          rewrite

    sso                                 alias=["localhost","example.com"]

    default-web-module=ROOT.war         enable-welcome-root=true

     

    and even

     

    [standalone@localhost:9999 virtual-server=default-host] cd access-log

    [standalone@localhost:9999 access-log] pwd

    /subsystem=web/virtual-server=default-host/access-log

     

     

    but it's unclear what one can do from here.  Command help is not "helpful":

     

    [standalone@localhost:9999 access-log] help --commands

    Commands available in the current context:

    batch             cd                clear             command

    connect           data-source       deploy            deployment-info

    help              history           ls                pwd

    quit              read-attribute    read-operation    undeploy

    version           xa-data-source

    To read a description of a specific command execute 'command_name --help'.

    For "raw" operations, i.e. not commands, read-resource-description is what you want: https://docs.jboss.org/author/display/AS71/Admin+Guide#AdminGuide-The%7B%7Breadresourcedescription%7D%7Doperation

     

    e.g.

    /subsystem=web/virtual-server=default-host:read-resource-description(operations=true, inherited=false)

  • 6. Re: Add access-log via jboss-cli ?
    alexh_97 Newbie

    I created an enhancement request for this:  https://issues.jboss.org/browse/AS7-4224

  • 7. Re: Add access-log via jboss-cli ?
    alexh_97 Newbie

    Kabir Khan wrote:

     

    For "raw" operations, i.e. not commands, read-resource-description is what you want: https://docs.jboss.org/author/display/AS71/Admin+Guide#AdminGuide-The%7B%7Breadresourcedescription%7D%7Doperation

     

    e.g.

    /subsystem=web/virtual-server=default-host:read-resource-description(operations=true, inherited=false)

     

    Kabir,

     

    This is a bit more helpful, but again, there doesn't seem to be a way to modify an existing virtual host.  The only operations that are listed are "remove" and "add".  Does this mean you need to remove the existing host and then re-add it with new attributes?

  • 8. Re: Add access-log via jboss-cli ?
    Kabir Khan Master

    I'm not too familiar with the web subsystem but seems the access log is at the address:  /subsystem=web/virtual-server=default-host/access-log. Since that resource is empty you'd typically execute 'add' to add it.

     

    So first let's look for it:

     

    [standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host/access-log=configuration:read-operation-names

    {

        "outcome" => "success",

        "result" => [

            "add",

            "read-attribute",

            "read-children-names",

            "read-children-resources",

            "read-children-types",

            "read-operation-description",

            "read-operation-names",

            "read-resource",

            "read-resource-description",

            "remove",

            "undefine-attribute",

            "whoami",

            "write-attribute"

        ]

    }

    It's there, let's see what it expects:

    [standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host/access-log=configuration:read-operation-description(name=add)

    {

        "outcome" => "success",

        "result" => {

            "operation-name" => "add",

            "description" => "Add access log configuration to this virtual server.",

            "request-properties" => {

                "pattern" => {

                    "type" => STRING,

                    "description" => "The access log pattern.",

                    "expressions-allowed" => false,

                    "required" => false,

                    "nillable" => true,

                    "min-length" => 1L,

                    "max-length" => 2147483647L

                },

                "rotate" => {

                    "type" => BOOLEAN,

                    "description" => "Rotate the access log every day.",

                    "expressions-allowed" => false,

                    "required" => false,

                    "nillable" => true

                },

                "prefix" => {

                    "type" => STRING,

                    "description" => "Prefix for the log file name.",

                    "expressions-allowed" => false,

                    "required" => false,

                    "nillable" => true,

                    "min-length" => 1L,

                    "max-length" => 2147483647L

                },

                "extended" => {

                    "type" => BOOLEAN,

                    "description" => "Enable extended pattern, with more options.",

                    "expressions-allowed" => false,

                    "required" => false,

                    "nillable" => true

                },

                "resolve-hosts" => {

                    "type" => BOOLEAN,

                    "description" => "Host resolution.",

                    "expressions-allowed" => false,

                    "required" => false,

                    "nillable" => true

                }

            },

            "reply-properties" => {},

            "read-only" => false

        }

    }

     

    So something like at least adds it to the model

    [standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host/access-log=configuration:add(pattern=aaaa,prefix=bbb,resolve-hosts=true,rotate=false,extended=false)

    {"outcome" => "success"}

    And it can be read

     

    [standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host/access-log=configuration:read-resource(recursive=true)

    {

        "outcome" => "success",

        "result" => {

            "directory" => undefined,

            "extended" => false,

            "pattern" => "aaaa",

            "prefix" => "bbb",

            "resolve-hosts" => true,

            "rotate" => false

        }

    }

    Exactly what I added I am not sure :-) To change values of an existing resource, if the attribute is read-write you can execute write-attribute, e.g.

     

    [standalone@localhost:9999 /] /subsystem=web/virtual-server=default-host/access-log=configuration:write-attribute(name=extended, value=true)

    {

        "outcome" => "success",

        "response-headers" => {

            "operation-requires-reload" => true,

            "process-state" => "reload-required"

        }

    }

  • 9. Re: Add access-log via jboss-cli ?
    Stan Silvert Master

    If you use the CLI GUI you wil see the help text that comes from read-opearation-description.  So you just right-click on a node and you get all the operations.  From there you can hover over an operation and see its help description.  Then if you select an operation you will get a dialog.  For each param in the dialog you can hover to see the help description of the param.  Fill in the form and you've got your fully-formatted command that you can submit.

     

    https://community.jboss.org/wiki/AGUIForTheCommandLineInterface

     

    Stan

  • 10. Re: Add access-log via jboss-cli ?
    alexh_97 Newbie

    Kabir,

     

    This is great - thank you!   

    Just for reference, here's some info on the virtual-host configuration options:  http://docs.jboss.org/jbossweb/7.0.x/config/host.html

    Unfortunately, the link to the access logging documentation within there seems to be broken, but seems like it could be found here:  http://wiki.apache.org/tomcat/AccessLogValve

  • 11. Re: Add access-log via jboss-cli ?
    Kabir Khan Master

    The cli stuff is our layer on top of the tomcat config. Under the hood you'll end up with something similar to the snippet you showed me going on but from the AS point of view you need to do this via standalone.xml or cli. Our docs are at http://www.jboss.org/jbossas/docs/7-x.html, although they seem to be missing the access log part. I'll ask someone who knows about that to fill it in.

     

    What you can do for now is get it working via xml, and then view the output of /subsystem=web/virtual-server=default-host/access-log=configuration:read-resource(recursive=true). If you can't figure out what values to add for the add operation from that post here, and similarly if you can please post what you used.