Enable the access_log function of JBoss7/WildFly

Source: Internet
Author: User

Preface

Access logs (access_log) are an important function for a website. With this feature, we can collect a lot of useful information to facilitate website O & M. Therefore, this feature is basically enabled for every website.

JBoss As 7 Configuration

By default, JBoss7.1 does not enable access_log. To enable this function, you need to modify $ JBOSS_HOME \ standalone \ configuration \ standalone. xml (domain. xml), the relevant modifications are as follows:

<Subsystem xmlns = "urn: jboss: domain: web: 1.0" default-virtual-server = "default-host">
<Connector name = "http" scheme = "http" protocol = "HTTP/1.1" socket-binding = "http"/>
<Virtual-server name = "default-host" enable-welcome-root = "true">
<Alias name = "localhost"/>
<Alias name = "example.com"/>
<Access-log/>
</Virtual-server>
</Subsystem>

After completing the preceding configuration and restarting the server, you can access your website, then you will see a file named access_log.2012-02-24 in the $ JBOSS_HOME \ standalone \ log \ default-host directory, which is the access log you need.

WildFly 8 Configuration

WildFly's method of enabling access_log is similar to that of JBoss 7. It also finds the corresponding web Container and adds the configuration, but the containers used by the two are different, in addition, the log storage directory must be specified in WildFly.


<Subsystem xmlns = "urn: jboss: domain: undertos: 1.0">
<Buffer-caches>
<Buffer-cache name = "default" buffer-size = "1024" buffers-per-region = "1024" max-regions = "10"/>
</Buffer-caches>
<Server name = "default-server">
<Http-listener name = "default" socket-binding = "http"/>
<Host name = "default-host" alias = "localhost">
<Location name = "/" handler = "welcome-content"/>
<Filter-ref name = "server-header"/>
<Filter-ref name = "x-powered-by-header"/>
<Access-log pattern = "common" directory = "$ {jboss. home. dir}/standalone/log" prefix = "access"/>
</Host>
</Server>
<Servlet-container name = "default" default-buffer-cache = "default" stack-trace-on-error = "local-only">
<Jsp-config/>
</Servlet-container>
<Handlers>
<File name = "welcome-content" path = "$ {jboss. home. dir}/welcome-content" directory-listing = "true"/>
</Handlers>
<Filters>
<Response-header name = "server-header" header-name = "Server" header-value = "Wildfly 8"/>
<Response-header name = "x-powered-by-header" header-name = "X-Powered-By" header-value = "Undertow 1"/>
</Filters>
</Subsystem>

As shown above, add a red line to enable the access_log function of WildFly 8, restart the server, and access ip: 8080 to generate access. log in the JBOSS_HOME/standalone/log directory..

Where

Prefix specifies the prefix name of the log file, that is, the file name.

Pattern specifies the log format

Pattern can be set in two ways. The first is pattern = "common", and the second is pattern = "combined"

The following is the log output in two formats tested by the author. Access localhost: 8080

Log output in common format is as follows:

The output of logs in combined format is as follows: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + CjxzdHJvbmc + PGltZyBjbGFzcz0 = "confluence-embedded-image" src = "http://wiki.cnsuning.com/download/attachments/16617941/access1.PNG? Version = 1 & modificationDate = 1392710363718 & api = v2 "alt =" ">

It can be seen that the log output in the second format is relatively specific, and the access_log format enabled in the actual development process needs to be determined based on the needs.

Conclusion

Enabling the access_log configuration ends here. If you have any questions, please refer to the following information or contact us directly. Thank you!

References

Https://issues.jboss.org/browse/WFLY-1721

Http://hi.baidu.com/saiv000/item/9ed9779aa1b1a2dc1f4271ea

Http://hooray520.iteye.com/blog/1335156

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.