WebLogic 12.1.2/12.2.1 HTTP扩展日志格式自定义配置问询
Absolutely, WebLogic versions 12.1.2 and 12.2.1 definitely support customizing your HTTP access logs into the key-value format you're looking for. Let's walk through exactly how to set this up:
Step 1: Confirm Extended Log Format is Enabled
Since you mentioned your current config already uses the "Extended" format, you're halfway there. Just double-check this is still selected in your server's HTTP log settings (we'll be modifying the extended fields next).
Step 2: Update the Extended Log Format String
Replace your current extended log format field string with this custom key-value formatted version:
date=date time=time method=cs-method uri=cs-uri status=sc-status duration=time-taken client_ip=c-ip
Breakdown of the Mapping
Each part maps directly to your original log fields, paired with your preferred key names:
date=date: Captures the request date (matches your originaldatefield)time=time: Captures the request time (matches your originaltimefield)method=cs-method: Maps the HTTP request method (GET/POST, originalcs-method)uri=cs-uri: Maps the requested URI path (originalcs-uri)status=sc-status: Maps the HTTP response status code (originalsc-status)duration=time-taken: Maps the request processing time (originaltime-taken)client_ip=c-ip: Maps the client's IP address (originalc-ip)
Step 3: Apply the Configuration
You can set this via either the WebLogic Console or directly in config.xml:
Option 1: WebLogic Console
- Log into your WebLogic Administration Console
- Navigate to Servers → Select your target server → Go to the Logging tab → HTTP Log sub-tab
- Ensure the Format dropdown is set to
Extended - Paste the custom format string into the Extended Log Format Fields text box
- Save your changes and restart the server to apply the new log format
Option 2: Edit config.xml Directly
- Locate the
<access-log>block for your server inconfig.xml(usually inDOMAIN_HOME/config) - Ensure
format="extended"is set on the<access-log>element - Add or update the
<extended-log-format>child element with your custom string:<access-log> <file-name>access.log</file-name> <format>extended</format> <extended-log-format>date=date time=time method=cs-method uri=cs-uri status=sc-status duration=time-taken client_ip=c-ip</extended-log-format> <!-- Other existing configs --> </access-log> - Save the file and restart the server
Step 4: Verify the New Format
After restarting, check your access.log file—you should see entries exactly like the sample you provided:
date=2018-01-18 time=11:39:19 method=GET uri=/test/service status=200 duration=1.406 client_ip=127.0.0.1
date=2018-01-18 time=11:39:19 method=POST uri=/test/service status=200 duration=0.169 client_ip=127.0.0.1
Quick Notes
- Make sure you use the exact WebLogic field variables (like
cs-method,sc-status) on the right side of the=sign—these are fixed identifiers WebLogic uses to populate log data. - A server restart is required for the new log format to take effect; WebLogic doesn't apply HTTP log config changes dynamically.
内容的提问来源于stack exchange,提问作者lichSkywalker

