Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3613512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:08:02+00:00 2026-05-18T22:08:02+00:00

Using the Log4J XMLLayout, I want to put a sequence of fields, wrapped in

  • 0

Using the Log4J XMLLayout, I want to put a sequence of fields, wrapped in tags, inside each log-event (log-line). <x>some info</x> <y>more info</y>.

This seems a natural way, in the context of an XML logger, to achieve a more structured log. Is there a standard way of doing this, or do I have to build the string with these tags myself?

I could also use a PatternLayout with XML tags wrapping certain fields. I’d have to escape the XML myself, and it seems that XMLLayout should be the one to use for XML.

Another problem is that XMLLayout puts the log-line into a CDATA block, which of course means that any XML in the line is not parseable as XML.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:08:02+00:00Added an answer on May 18, 2026 at 10:08 pm

    There doesn’t seem to be built in functionality for this.

    I’d suggest doing this: since you already have log4j, you have it’s source code.

    Find the file org.apache.log4j.xml.XMLLayout. Copy it, rename it’s package name to something that will fit into your application, simply strip \r\n where appropriate (this file isn’t large, so it shouldn’t be a problem) and make a reference in log4j’s configuration file to use your new layout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using Log4j in our project for logging. I want to log some
I want to write log for each thread using log4j and log file name
I am traying to get log4j to log to file in XMLLayout using the
I am using log4j to log my exceptions. I want to log whatever I
i am using log4j as my logging library, and i want the generated log
When using log4j, the Logger.log(Priority p, Object message) method is available and can be
I'm using log4j in an app I'm developing to eventually run inside Tomcat/JBoss, but
My procedure for using log4j is this: put a .properties file somewhere in a
I have sixteen servers using Log4J logs, accessible by ssh. I want to see
I'm using log4j for record my program's log. The code is like this: static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.