I was trying to have log4j roll log files on daily basis with a maxBackUpIndex.
This as per many blogs and documentation is not available.
So from some blog, I figured out that we can update the DailyRollingFileAppender class file itself to have maxBackupIndex property and its implementation.
I was able to add the new implementation and replace the original DailyRollingFileAppender file with new updated one.
But the updated log4j.jar does not reflect my change, it says "log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender"
Please suggest, if anyone has encountered something similar to this.
Figured it out, the class file was not getting complied - copied in the jar properly.
Created the jar from jar - cvf command and it worked fine.
Related
Bit of a newbie with Log4j please forgive me if I'm doing something daft.
Trying to get log4j to write logs to a file while I am still working on it in IntelliJ.
No issues with getting sl4j/log4j outputting to the console/stdout whatsoever, that's fine. Issue is with getting it to write those same messages to a log file.
Here is what I have:
My dependencies are, I think, in order:
I have created a logger:
I have added a log4j.propeties file in my resources:
I have added a reference to the log4j.properties file in the intelij run configuration (the redacted part is just a folder name):
And when I run the app I see that the logging is in place on the console/stdout:
But I do not get a log file ( mylogs.log)as a result of the 'file' appender. I've tried different log file paths but that makes no difference. I'm not sure whether I have to run the application a jar for this to work, perhaps?
In short, I'm not sure what I'm doing wrong and would appreciate any assistance.
Thanks!
In this previous question, I was trying to rework some Matlab code and figure out a package called javaplex to be compatible with Octave; it uses Java, but is tooled for Matlab, hence that issue. Now in an interval of time, I was busy/running simulations, and hadn't gotten around to a final step - actually using the package, with most all of the difficulties worked out. It turns out that another step exists: I need to convert an Octave array to a Java array (although I'm not sure why this issue didn't come up in Matlab).
To do so, I have turned to this script, in which the comments indicate that when using it, it
Assumes the JIDT [Java Information Dynamics Toolkit] jar is already on the java classpath - you will get a java classpath error if this is not the case.
So I go to the JIDT GitHub page and download this package. Now I am not a very avid user of java, so I believe I am failing to see something fairly straightforward: I am not sure where the "JIDT jar" is that is referenced in the above block quote! I can't find such a particular jar file to put in Octave's java classpath. In this tutorial for JIDT, they say you need the "infodynamics.jar" file in the classpath (page 9). I'm not sure what jar file I should be looking for, and where. Any help understanding the nature, name and location of this jar file (within the infodynamics toolkit folder) would be appreciated!
As an inevitable follow-up question, because this will come up upon resolving this issue, I would like to clarify the following procedure is how to add a jar file to the Octave (static) java classpath (following this answer here, I wasn't sure if I was implementing correctly):
I create a file called "javaclasspath.txt" inside of the directory I use in Octave.
I enter the name of files as follows: "./path/to/your-file.jar"
I suppose my main issue here is where do I start the path (all the way back with "C:/..."?), and do I put this "javaclasspath.txt" file in the directory folder I will be using most of the time in Octave?
Edit: I cannot find "infodynamics.jar" as shown here:
The JIDT jar is named infodynamics.jar and it is located in the root of the downloads infodynamics-dist-1.4.zip file.
im not sure if its a jira problem or me not doing it properly, the latter more likely!
I have a file properties file called rootcause it is in a directory sturcture net/mycompany/rootcauseanalysis
in my jira atlassian-plugin.xml file I have
<resource type="i18n" name="i18n" location="net.mycompany.rootcauseanalysis.rootcause"/>
in my properties file I have properties defined like
rootcause.name=My plugin
in my java file which extends JiraWebActionSupport i use
String str=getText("rootcause.name");
when I print this out I get rootcause.name instead of the My plugin value I was expecting to get.
I have tried troubleshooting this problem by changing directory structure, file names, property names, using " and ' running out of ideas now!
done it :D
This is a hack I found on the forums solved my problem
http://forums.atlassian.com/thread.jspa?messageID=257351842�
I'm trying out log4j in a simple test app. I create a new Java project in eclipse and add the log4j JAR (v1.2.16) to my build path. I then create a simple class that prints Hello World. Then I use the log4j Logger class to log a info message. When I run the app, I see the log message, using what I assume is the default appender and layout. Great. What I'm having trouble with is adding my own configuration. This is what I've done:
Created a log4j.properties file with a custom appender and log level and placed it into the src folder (which upon compilation gets copied to the bin folder). Run the app - no change.
I try adding PropertyConfigurator.configure("log4j.properties"). Run the app - no change. No errors, but no change.
What do I have to do to get log4j to load my configuration file?
Look in the manual under the heading Default Initialization Procedure, where you'll find the following:
The exact default initialization algorithm is defined as follows:
Setting the log4j.defaultInitOverride system property to any other value than "false" will cause log4j to skip the default
initialization procedure (this procedure).
Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify
the default initialization file is through the log4j.configuration
system property. In case the system property log4j.configuration is
not defined, then set the string variable resource to its default
value "log4j.properties".
Attempt to convert the resource variable to a URL.
If the resource variable cannot be converted to a URL, for example due to a MalformedURLException, then search for the resource from the
classpath by calling
org.apache.log4j.helpers.Loader.getResource(resource, Logger.class)
which returns a URL. Note that the string "log4j.properties"
constitutes a malformed URL. See
Loader.getResource(java.lang.String)
for the list of searched locations.
If no URL could not be found, abort default initialization. Otherwise, configure log4j from the URL. The
PropertyConfigurator
will be used to parse the URL to configure log4j unless the URL ends
with the ".xml" extension, in which case the
DOMConfigurator
will be used. You can optionaly specify a custom configurator. The
value of the log4j.configuratorClass system property is taken as the
fully qualified class name of your custom configurator. The custom
configurator you specify must implement the Configurator interface.
Argh. I discovered the problem was that eclipse had imported the wrong Logger class. It had imported java.util.logging.Logger which of course has it's own configuration that is different from log4j. Oh well, hope somebody else does this and gets it solved by reading this question.
You can enable log4j internal debugging by setting the log4j.debug system property. Among other things, this will cause log4j to show how it is configuring itself.
You can try explicitly setting the URL to the configuration file with the log4j.configuration system property.
See also: this question.
The problem may be in the classpath, if the classpath was defined.
The reason it wasn't loading (in my case): There was a conflicting log4j.properties file in one of my jars, and it was overloading the one in my classpath.
In short, if your log4j.properties file isn't loading, there might be another one somewhere else overriding it.
Just thought I'd throw this in too, in case anyone else runs into this. I just spent the last 5 hours trying to figure out why my default log4j.properties wouldn't load.
log4j.properties should be in your classpath. The "src folder" which is copied to the "bin folder" (I assume you are speaking of a Eclipse setup here), normally belongs to your classpath, so it should be found (are you placing it at the top of the "src" folder, right?)
I know this is a couple of months old, but I feel the need to point out that the scr folder isn't "copied" to the bin folder, nor is it part of your runtime classpath....(build path is not runtime classpath!). Eclipse compiles the source files in the src folder to the bin (or whatever you like) folder. It's the bin folder that is part of your runtime classpath.
Just wanted to point this out as these threads are often read by very junior programmers as well, and I'm always frustrated that most of them don't grasp the finesse of the Java classpath, and hence make avoidable mistakes against it.
Just throwing it out there to anyone who is struggling to get log4j.properties filed loaded.
I fixed mine by adding the following line:
-Dlog4j.defaultInitOverride=TRUE
Turns out using that JVM parameter, it possible to tell Log4j not to use the Default Initialization Procedure and create your own.
I struggled with mine. I did from clean JAR build to entire REPO pull, nothing work. Combination of that and clean up of class file made it work.
I am using SVNKit 1.3.2 and trying to obtain working copy revision number.
Working copy is checkouted also with SVNKit, but when I'm trying to call
clientManager.getLookClient().doGetYoungestRevision(destination);
I got FileNotFoundException telling me that 'format' file is not found under destination path, ex /path/to/working/copy/format
I can see 2 troubles:
- It tries to access 'format' file right in working directory root, while this file supposed to be in .svn folder
There is not file in this .svn folder.
Any clues? Thank you!
Seems to be it should be done through SVNStatusClient:
clientManager.getStatusClient().doStatus(destination, false).getRevision().getNumber();
Though still don't understand what's the problem with doGetYoungestRevision(destination)...
It is not working because doGetYoungestRevision is for a repository, not for a working copy.
I was hoping to achieve the same things as you, and found out that when destination is pointing to a repository, it returns the last revision number of the repository.
The class in itself is for working with repository, you can look at the documentation here.