Cannot Logging to database using Log4J.

Solution Unverified - Updated -

Issue

  • I want to Logging to Postgresql Database.
  • I try to add "log4j2.appender.DB" to org.ops4j.pax.logging.cfg. But, the logging does not work.
# Define the DB appender
log4j2.appender.DB=org.apache.log4j.jdbc.JDBCAppender

# Set JDBC URL
log4j2.appender.DB.URL=jdbc:postgresql://localhost:5432/redhat_log

# Set Database Driver
log4j2.appender.DB.driver=org.postgresql.Driver

# Set database user name and password
log4j2.appender.DB.user=user
log4j2.appender.DB.password=paswd

# Set the SQL statement to be executed.
log4j2.appender.DB.sql=INSERT INTO LOGS VALUES('%x','%d','%C','%p','%m')

# Define the layout for file appender
log4j2.appender.DB.layout=org.apache.log4j.PatternLayout

Environment

  • Red Hat Fuse
    • 7.0.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.