• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Logger not logging to file?

 
Ranch Hand
Posts: 73
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I am using a root logger to write logs to a file. But file itself is not created.

I have created a maven project. The log4j2.properties file is placed in src/main/resources.

pom.xml


Log4jDemo.java


log4j2.properties

 
Sheriff
Posts: 27227
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest providing the full path to the log file. Using a relative path could lead to confusion.

And I don't understand the append/overwrite distinction... it looks to me like every time you write an entry to the log file, you're going to overwrite the previous entry. But that's probably just me not understanding what the distinction is for and why it even exists.
 
Marshal
Posts: 75836
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Overwrite probably means you only find the most recent exception in the log file. Append probably means your log file is (approx.) 375693875983275936453 lines long
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unrelated, but do yourself a favour and update the Log4J version to 2.17.1 as soon as you can. That's basically the only secure version since ever. With the version you're using, you're highly vulnerable for a number of vulnerabilities, with Log4Shell the worst of the bunch.
 
Saloon Keeper
Posts: 25608
183
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Append" means keep the existing log file and add onto the end when you run the app. No problem with that as long as you do make sure that it doesn't get forgotten and grow until it eats your disk.

I'll confirm Paul's other suggestion. It's quite hazardous to use a relative path for a logfile. It's entirely possible that the log was actually created, but you don't know where!
 
reply
    Bookmark Topic Watch Topic
  • New Topic