How to get velocity.log file using log4j.properties file. i don't want to involve velocity.properties file - log4j

Now my velocity.log and velocity.log.1 are at :installed software eclipse Kepler\eclipse-64\eclipse
i don't know how these files are created here.

By default, Velocity log files are created in the current working directory.
To change this behavior, you'll have to somehow configure Velocity. If you don't want to mess with velocity.properties, then you can configure Velocity using Java, as described in this documentation section which explains how to have Velocity log to an existing Log4j logger.

Related

How to read level changes from log4j.xml when application is running

I am running a executable jar file, which logs using log4j.xml(version 1.2).
Whenever i change the log level in the xml file, i have to restart the java application for the new log level to reflect.
Can i add some configuration in the log4j.xml so that new log level will be taken into account without application restart?
Thanks,
-Venkat
Log4j 1.x has reached end of life on August 5, 2015. So I would like to recommend you to use log4j 2.x which supports this with the monitorInterval configuration.
However according to the log4j 1.x docs here it does support log level changes runtime.
How can I change log behavior at runtime?
Log behavior can be set using configuration files which are parsed at
runtime. Using configuration files the programmer can define loggers
and set their levels.
The PropertyConfigurator defines a particular format of a
configuration file. See also the examples/Sort.java example and
associated configuration files.
Configuration files can be specified in XML. See log4j.dtd and
org.log4j.xml.DOMConfigurator for more details.
See the various Layout and Appender components for specific
configuration options.
In addition to configuration files, the user may disable all messages
belonging to a set of levels. See next item.

How can I retain existing log file permissions with Log4J DailyRollingFileAppender

I have a jar file which internally use log file to write messages. Using this jar I have developed a Perl module. The usage of this module is across out firm. So I have given 666 permissions on all the log files so that everyone can use the module. The issue is the jar file internally uses log4j and the appender is DailyRollingFileAppender which is resetting the permissions on the log files to 664 after rolling and certain people are not able to use the module.
Is there a way to mention to log4j to retain the existing permissions of the log file ? If not, can anyone suggest alternative ?
This is the responsibility of the operating system. When Log4j rolls a log, the OS will create that new file according to its own rules.
You should be able to reproduce this manually, by opening a shell in the log directory and running touch testfile - the file testfile should exhibit the same permissions as new log4j files.
You need to look at the file permissions on the directory, those that are inherited by new files in that directory. You may also need to tinker with the user's umask setting.
If you can reproduce the problem without using log4j or java, then it becomes easier to solve, but would be best asked on superuser.com.

Log4J and Java Web Start, how to alternate between different configurations?

i'm starting with Log4J and i want to have a default log4j.properties in our Java Web Start distributed application, which only logs errors and important events.
But if something was wrong in one client i want to have a more detailed log, the way to do this is to define an alternate log4j configuration file in this client. This can be done by specifiying the alternate config file with the log4j.configuration system property.
but... How can i define an system property for this particular client in a java web start launched application? (i know that i can define theese propeties in the .jnlp file, but this affects all clients).
Our users work in windows environment but they often have a restricted permissions computer and they can't acces My Pc->Properties-->Advanced Options-->Enviroment Variables (i'm in a spanish configured computer i don't know the exact names in english).
Can you access to a defined directory on the client disk ?
If you can, you can define a convention : if no configuration file is found in the directory, the default config is used. Else, the specific configuration file is loaded.
You can do that with the PropertyConfigurator class of Log4J :
File log4jConfigFile == new File(conventionLocation);
if(log4jConfigFile.isFile() && log4jConfigFile.exists()) {
PropertyConfigurator.configure(conventionLocation);
} else {
PropertyConfigurator.configure(defaultEmbeddedJarLocation);
}
First off if you are using applets you should use an appender that can write to a remote location so you can actually see the errors without being physically on the local machine that the applet is running. Appender Types. Next, you need to create an appender with a threshold of whatever level you are logging the normal "access" type messages. Set the layout to whatever you desire. Then create another appender with a level of at least the level you log "errors" at as well as its own format that suits your needs as being "more detailed". That way when your code calls an error message it will use that different layout. Log4j is fairly complex but not impossible to understand. Look at the documentation at The log4j site and get your feet wet on some simple logging. After that you should be able to modify the code to get what you desire.

Logging via FileAppender

here is an easy question coming:
i am trying to use log4net to log the infos on a file. i wrote
< file value="log-file.txt" /> into my appender tag in app.config. and now wondering where the log-file.txt is positioned and whether it is created automatically or i should create it by myself.
i am using c# - wpf
It should be in the Debug\Bin or Release\Bin folder.
if its not there, try specifying full path.
The file will automatically be created if it doesn't exist.
It may require that the application has write permission to the folder where the logfile is placed.
As Orentet mentions this is normally the bin folder.

How do I add a project to CruiseControl.NET?

I am looking at the cruisecontrol web dashboard. I can see one farm and one server. However, I don't see any way to add a project?
Is this something I can do with the UI or do I need to edit the config file by hand?
You'll need to edit the ccnet.config file by hand (located within the CruiseControl directory) to add projects. There are some graphical tools to help you do this however you do get used to doing it by hand fairly quickly - just have the documentation near by!
Update: An example of one such tool is http://www.codeplex.com/ccnetconfig
You can use CCNETConfig to edit the config file through an UI although it doesn't support higher version > CruiseControl.NET 1.4.
You have to basically edit the configuration file by hand, however I have it setup so that the raw config file is split into different include files, each of which is setup in my source control system. Then I created a project for the configuration, and then for the whole config. So when something changes in the config, CC.NET itself pulls out the changes, recreates it's config files and the refreshes the system configuration.
This means that anyone can edit the config (if they can access the files in sourcecontrol), and no-one has to go into the program files directory of the CC.NET machine itself.
Not sure whether this answers the question you asked, but this is how our setup works

Resources