Logs
Nginx Error Log
Parses Nginx error log lines.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("^(\\d{4}/\\d{2}/\\d{2} \\d{2}:\\d{2}:\\d{2}) \\[(\\w+)\\] (\\d+)#(\\d+): (.*)$", "");
const input = "2023/10/11 10:00:00 [error] 1234#5678: *1 connect() failed";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
pyPython
import re
pattern = re.compile(r"^(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(\w+)\] (\d+)#(\d+): (.*)$")
input_text = "2023/10/11 10:00:00 [error] 1234#5678: *1 connect() failed"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(\w+)\] (\d+)#(\d+): (.*)$`)
input := `2023/10/11 10:00:00 [error] 1234#5678: *1 connect() failed`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
regexengine-agnostic
^(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(\w+)\] (\d+)#(\d+): (.*)$Raw source: ^(\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}) \[(\w+)\] (\d+)#(\d+): (.*)$
How it works
Captures timestamp, log level, PID, TID, and the error message from standard Nginx error log format.
Examples
Input
2023/10/11 10:00:00 [error] 1234#5678: *1 connect() failedMatches
2023/10/11 10:00:00 [error] 1234#5678: *1 connect() failed
Common use cases
- •Nginx monitoring
- •DevOps dashboards
- •Incident response
Related patterns
Log Level
LogsMatches standard log level keywords in log lines.
Apache Common Log Format
LogsParses Apache Common Log Format entries.
CloudWatch Log Stream Path
LogsMatch AWS CloudWatch log group / stream paths like `/aws/lambda/my-function` or `/aws/ecs/cluster-name`.
JSON Log Line (Single-Line Object)
LogsMatch a single-line JSON object — typical of structured logging from services like slog, Bunyan, or Pino.