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

  • SEARCH
  • Home
  • 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 8960029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:34:49+00:00 2026-06-15T15:34:49+00:00

I am trying to log using log4j in my Java EE application in the

  • 0

I am trying to log using log4j in my Java EE application in the following way where i have defined a log4j.xml in the application.

I am trying to access it using

   DOMConfigurator.configure( "src/log4j.xml");
   logger.warn( "Login Process has started a warning message" );

but it keeps throwing the following error

** edited error message

log4j:ERROR Could not parse file [src/log4j.xml].
 java.io.FileNotFoundException: D:\src\log4j.xml (The system cannot find the path s     pecified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:749)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:866)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755)

When i provided the absolute path everything is working .

So whats the way to achieve this? I am using 1.2.16.jar version of log4j

and i get following warning each time i build the app

log4j:WARN No appenders could be found for logger     (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Edited:
Application struture

Myapp
  src
  conf
  target

and i have palced log4j.xml under folder src

log4j.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p %c{1} - %m%n" />
    </layout>
</appender>
   <appender name="Log" class="org.apache.log4j.FileAppender">
    <param name="File" value="Web.log" />
    <param name="Append" value="true" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1}: %m%n" />
    </layout>
</appender>

<logger name="com.web" additivity="false">
    <level value="info" />
    <appender-ref ref="Log" />
</logger>

</log4j:configuration>

Thanks

  • 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-06-15T15:34:51+00:00Added an answer on June 15, 2026 at 3:34 pm

    Better put it inside src/main/resources folder.

    You can also rename it to log4j.properties, depending on your file format.
    And you should have either log4j.jar, or if you are using maven add dependencies to pom.xml file.

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

Sidebar

Related Questions

I want to maintain two Log Files in my web-application using apache Log4j.jar: 1)
I am trying to create 2 log files using log4j using this configuration: log4j.rootLogger=debug,stdout,logfile
I'm trying to log into a html file using Log4j filappender. My properties file
I am trying to log messages in WCF using the following code, but Message
I am trying to capture the logs using log4j in Java. The executeable is
I have Spring MVC application integrated with Hibernate. I'm trying to log jdbc SQL
I am trying to use log4j for my Java desktop application that i am
I am trying to write a log parser for log4j. I have a regular
I am trying to implement a simple log using Nlog 1.0, using the following
I'm facing a problem when trying to log my application using log4net. My application

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.