How can i wrote configuration file in Log4j

iam new log4j .i have seen one small programme in log4j examples folder ..i e. shown below
Sort.java
=====
package examples;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
Example code for log4j to viewed in conjunction with the {@link
examples.SortAlgo SortAlgo} class.
<p>This program expects a configuration file name as its first
argument, and the size of the array to sort as the second and last
argument. See its <b>source
code</b> for more details.
<p>Play around with different values in the configuration file and
watch the changing behavior.
<p>Example configuration files can be found in <a
href="doc-files/sort1.properties">sort1.properties</a>, <a
href="doc-files/sort2.properties">sort2.properties</a>, <a
href="doc-files/sort3.properties">sort3.properties</a> and <a
href="doc-files/sort4.properties">sort4.properties</a> are supplied with the
package.
<p>If you are also interested in logging performance, then have
look at the {@link org.apache.log4j.performance.Logging} class.
@author Ceki G&uuml;lc&uuml; */
public class Sort {
static Logger logger = Logger.getLogger(Sort.class.getName());
public static void main(String[] args) {
     if(args.length != 2) {
          usage("Incorrect number of parameters.");
     int arraySize = -1;
try {
          arraySize = Integer.valueOf(args[1]).intValue();
          if(arraySize <= 0)
               usage("Negative array size.");
catch(java.lang.NumberFormatException e) {
usage("Could not number format ["+args[1]+"].");
PropertyConfigurator.configure(args[0]);
int[] intArray = new int[arraySize];
logger.info("Populating an array of " + arraySize + " elements in" +" reverse order.");
for(int i = arraySize -1 ; i >= 0; i--) {
          intArray[i] = arraySize - i - 1;
SortAlgo sa1 = new SortAlgo(intArray);
sa1.bubbleSort();
sa1.dump();
// We intentionally initilize sa2 with null.
SortAlgo sa2 = new SortAlgo(null);
logger.info("The next log statement should be an error message.");
sa2.dump();
logger.info("Exiting main method.");
static void usage(String errMsg) {
     System.err.println(errMsg);
     System.err.println("\nUsage: java org.apache.examples.Sort " + "configFile ARRAY_SIZE\n"+
"where configFile is a configuration file\n"+" ARRAY_SIZE is a positive integer.\n");
System.exit(1);
and
SortAlgo.java
==========
package examples;
import org.apache.log4j.Category;
import org.apache.log4j.NDC;
Example code for log4j to viewed in conjunction with the {@link
examples.Sort Sort} class.
<p>SortAlgo uses the bubble sort algorithm to sort an integer
array. See also its <b>source
code</b>.
@author Ceki G&uuml;lc&uuml; */
public class SortAlgo {
final static String className = SortAlgo.class.getName();
final static Category CAT = Category.getInstance(className);
final static Category OUTER = Category.getInstance(className + ".OUTER");
final static Category INNER = Category.getInstance(className + ".INNER");
final static Category DUMP = Category.getInstance(className + ".DUMP");
final static Category SWAP = Category.getInstance(className + ".SWAP");
int[] intArray;
SortAlgo(int[] intArray) {
this.intArray = intArray;
void bubbleSort() {
CAT.info( "Entered the sort method.");
for(int i = intArray.length -1; i >= 0 ; i--) {
NDC.push("i=" + i);
OUTER.debug("in outer loop.");
for(int j = 0; j < i; j++) {
     NDC.push("j=" + j);
     // It is poor practice to ship code with log staments in tight loops.
     // We do it anyway in this example.
     INNER.debug( "in inner loop.");
if(intArray[j] > intArray[j+1])
     swap(j, j+1);
     NDC.pop();
NDC.pop();
void dump() {   
if(! (this.intArray instanceof int[])) {
DUMP.error("Tried to dump an uninitialized array.");
return;
DUMP.info("Dump of integer array:");
for(int i = 0; i < this.intArray.length; i++) {
DUMP.info("Element [" + i + "]=" + this.intArray);
void swap(int l, int r) {
// It is poor practice to ship code with log staments in tight
// loops or code called potentially millions of times.
SWAP.debug( "Swapping intArray["+l+"]=" + intArray[l] +
     " and intArray["+r+"]=" + intArray[r]);
int temp = this.intArray[l];
this.intArray[l] = this.intArray[r];
this.intArray[r] = temp;
This program expects a configuration file name as its first
argument, and the size of the array to sort as the second and last
argument. See its <b>source
code</b> for more details.
please help me how can write that configuration file
thanks

Hi bala,
check that log4j manual I pointed to in yer previous thread.
This is a pot-boiler config file... Copy it into some file say "props.conf" and use it.
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%nCheers,

Similar Messages

  • How can I remove a file on server w/ my JSP app running on Tomcat 7 ?

    First of all, I'm posting here because I found it the closest to java web development in the forums listing.
    How can I remove a file on the server side with my JSP app running on Tomcat 7 ? I did it in a JSE app by changing permissions, but how can I do it for a simple JSP app ?
    My code is
    public static void excluirArquivos(String nomeArquivoExcluido) {
              File arquivoExcluido = new File (nomeArquivoExcluido);
              arquivoExcluido.setWritable(true, true);
              SecurityManager sm = new SecurityManager();
              try {
                   sm.checkDelete(arquivoExcluido.getAbsolutePath());
                   System.gc();
                   if (arquivoExcluido.delete()) System.out.println("File '" + nomeArquivoExcluido + "' successfully removed.");
                   else System.out.println("File '" + nomeArquivoExcluido + "' wasn't removed somehow.");
              } catch (SecurityException se) {
                   System.out.println("File '" + nomeArquivoExcluido + "' can't be excluded. There is no permissions.");
         }And it always falls on the catch statement.

    899238 wrote:
    How can I remove a file on the server side with my JSP app running on Tomcat 7 ? I did it in a JSE app by changing permissions, but how can I do it for a simple JSP app ?1. make sure that the JVM has the (filesystem) rights to be able to remove said file
    2. make sure the file is in fact not locked (for example, opened by another process)
    3. use File.delete()
    There is no guarantee that you can delete a file, you can only make an attempt. There can be any number of reasons, most if not all of them not related to code, that the deletion of a file does not work.

  • How can i see PDF files in Nokia 5230

    How can i see PDF files in Nokia 5230

    sandy2410 wrote:
    @moonnight12
    Adobe has its own pdf reader for symbian s60 3rd edition devices.
    http://www.adobe.com/products/acrobat/readerforsymbian.html
    Hopefully this helps
    Cheers
    Sandy
    Did you actualy read this. " QuickOffice is the Exclusive S60 Provider of this release".
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

  • How can I copy a file through a logon script with UAC enabled ?

    Hello,
    I have a batch that is copying a file to "%public%\desktop\" (windows 7) folder through a logon GPO (GPO from user configuration).
    Everytime I try, I have an "access denied". I know it is because UAC and I don't want to disable it.
    Through explorer.exe, I can copy this file with no problem with this same account.
    How can I copy a file to such folder through group policy please ?
    I dont want to use GPP as the script is used on WinXP too and I dont have the hotfix to support GPP on this operating systems.
    Thank you

    > I have a batch that is copying a file to "%public%\desktop\" (windows 7)
    > folder through a logon GPO (GPO from user configuration).
    > Everytime I try, I have an "access denied". I know it is because UAC and
    > I don't want to disable it.
    Since you are copying to a non-user specific-directory, I'd recommend
    using a startup script instead...
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • When bates numbering a .pdf in XI, how can I change the file name to include the bates number AND its name?  I know under file output, there is an option for either/or.  I want both.  Thank you.

    when bates numbering a .pdf in XI, how can I change the file name to include the bates number and the file name?  I know under "file output: it's either/or.  I need both.  Thanks!

    Long ago I wrote a little demo using the touch command. Check out the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=25128#M25128
    LabVIEW Champion . Do more with less code and in less time .

  • HT204382 how can i open this file Đế Cẩm 54 54 DVDRip VNLT tập 1 dailymotion.flv ?

    how can i open this file Đế Cẩm 54 54 DVDRip VNLT tập 1 dailymotion.flv ?

    angelinedinh wrote:
    how can i open this file Đế Cẩm 54 54 DVDRip VNLT tập 1 dailymotion.flv ?
    Where did the file come from?
    Thanks
    Pete

  • "dtutil", how to tell which configuration file for packages using after deployment?

    Hello All, 
    Trying to achieve this feature, 
    Using DOS command to automatic my deployment process--glad I found dtutil. However, it doesnt give you any chance to identify which configuration file to be used by SSIS packages after deployment.
    Deployment Method: file deployment
    Configuration sued: XML file and SQL Table. IN XML file, it tells which DB connection for packages to look up the configuration table.
    Who can share some thoughts on this?
    Derek

    It is NOT about sequence.
    It is about how to point which configuration file to be used by deployed packages as during the "dtutil.exe"
    deployment, you dont have chance to identify which physical location confg files to be used.
    Derek
    That you do only at the time of execution of packages. By default it uses configuration settings created at design time within the package. If you want to override it, you can use \Configfile switch of dtexec for that. You can also set explicit values for
    properties using /SET switch
    http://technet.microsoft.com/en-us/library/ms162810(v=sql.105).aspx
    See this to understand how configs are applied in runtime
    http://technet.microsoft.com/en-us/library/ms141682(v=sql.105).aspx
    and this to understand behaviour difference in ssis 2008 
    http://technet.microsoft.com/en-us/library/bb500430(v=sql.105).aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How can I transfer my files/system in VAIO laptop (w/ S400 Firewire port) to my New Macbook Pro?

    How can I transfer my files/system in VAIO laptop (w/ S400 Firewire port) to my New Macbook Pro?
    Do I need to buy an adapter? How do I setup the software to make these two system connected?

    r95941081 wrote:
    Thanks for your answering. But the issue is that I'll often transfer a large amount files from PCs to the Macbook, and I'm explring the way to use firewire since there is indeed an i-S400 port in the VAIO laptop, and it's much faster.
    USB 2 is faster than Firewire 400 and USB 3 is faster than Firewire 800
    If it was another Mac you were transferring from then you could use Firewire Target Disk Mode which makes the boot drive of the old Mac appear on the desktop of the new Mac to rapidly copy files, but you have a Windows PC with no FWTDM capability.
    So to connect the two machines requires a network be setup over Ethernet and mucking around with the complexities of all that and it still takes awhile to finish. One can't setup a network with a PC over USB or Firewire, only Firewire with another Mac.
    You get a external USB drive, USB 3,2,1 is fine and just drag and drop copy, the machine does all the work and you go do something else until it's finished, then repeat the same with the Mac.
    Fast simple and effective, let it copy overnight if you have too.
    I routinely clone my entire hard drive via USB 2 and it only takes a hour and a half for 350GB.
    By the time you figure out how to network a Mac and a PC over Ethernet and getting it work to transfer files, you could be done already via USB.

  • How can I pass a file refnum into and out of external c++ code? What type does it convert to in c++?

    I am trying to write external c++ code that will read a file already opened by Labview and therefore assigned a refnum. (Unfortunately, I definately can't use the standard Labview vis.) However I am not sure what c++ type to use in order to manage the refnum.
    All help and thoughts appreciated. Thanks,
    Joanna

    You could do ALL your file handling in C or C++ (MFC CFile for
    example) and pass Microsoft file handles into and out of LabVIEW
    instead of LabVIEW file references into and out of C. This may be an
    easier way to attack the problem.
    You could create a DLL in MSVC that exports a FileOpen function, a
    FileClose function and a FileRead and/or FileWrite Function and then
    call that DLL from place to place as required in your code.
    It would help us if you would explain what kind of data you are trying
    to read or write and what the application is. Is it binary data?
    text files? Do you need some special Win32 file system feature like
    file mapped memory? I guess what I am asking is what is your
    motivation for doing file handling in C or C++?
    Douglas De Clue
    LabVIEW developer
    [email protected]
    "Rolf" wrote in message news:...
    > A LabVIEW file refnum is an internal Magic Cookie to LabVIEW and there is no
    > way to directly extract the actual information assigned to that Magic
    > Cookie.
    > However the CIN Reference Manual describes one function which allows to
    > retrieve a lower level "File" handle and at least on Windows 32 bit and
    > LabVIEW
    > from version 5 up to and including 6.1 this "File" LabVIEW datatype directly
    > maps
    > to the Win32 API "FILE" Handle.
    >
    > The function to use is
    >
    > MgErr FRefNumToFD(LVRefNum refNum, File *fdp);
    >
    > It is declared in extcode.h or one of its dependant headers and exported
    > from "labview.lib"
    > all located in the cintools directory and you can link this lib also to a
    > normal DLL project.
    > However calling this DLL then from any other process than LabVIEW or a
    > LabVIEW
    > executable will not initialize the DLL anymore correctly.
    >
    > Your best option if you need to write in C(++) should be to use the LabVIEW
    > file manager
    > functions described on the External Code Manual (manual/lvexcode.pdf) on
    > this File handle.
    > If you need to use directly some Win32 API functions with it please note
    > that although currently
    > the "File" in the LabVIEW file manager functions matches the FILE in Windows
    > 32 bit API
    > functions this is an undocumented and hence unsupported feature. The next
    > LabVIEW version
    > may actually use a different datatype for its "File" parameter to the
    > LabVIEW file manager calls
    > and your use of assuming File == FILE may simply crash.
    >
    > Also operating on a file refnum in LabVIEW which has been accessed directly
    > with Win API
    > functions may result in strange behaviour such as the file read/write mark
    > not being updated as
    > you would maybe expect it.
    >
    > "Jo" wrote in message
    > news:50650000000800000016520000-1023576873000@exch​ange.ni.com...
    > > How can I pass a file refnum into and out of external c++ code? What
    > > type does it convert to in c++?
    > >
    > > I am trying to write external c++ code that will read a file already
    > > opened by Labview and therefore assigned a refnum. (Unfortunately, I
    > > definately can't use the standard Labview vis.) However I am not sure
    > > what c++ type to use in order to manage the refnum.
    > > All help and thoughts appreciated. Thanks,
    > > Joanna

  • When I import my Sony video, which is in m2ts format, the file size is a few times larger.  This affects the volume of clips for creating the blu-ray or DVD discs.  How can I squeeze the file size without sacrificing the quality of output?

    When I import my Sony video, which is in m2ts format, the file size is a few times larger.  This affects the volume of clips for creating the blu-ray or DVD discs.  How can I squeeze the file size without sacrificing the quality of output?  Is there any other ways of achieving this?

    wongrayd wrote:
    Thanks.  I do not have the experience on burning discs from iMovie for the movie after editing (ie for video discs players).  It seems that i cannot find the relevant command in the tool bar for this purpsoe.  Would you please show me the way?
    The command is gone because iDVD has been discontinued by Apple. After Apple discontinued iDVD they removed the iDVD burning link from iMovie. I still use iDVD sometimes, only because I have an old copy.
    wongrayd wrote:
    You have mentioned about Handbrake as a converter.  What is the RF no. (under Constant Quality) meant?  It seems that the smaller the no. is, the better quality will be.  What is the optimal no.? or should we use the Average Bitrate? Again, what is the best rate?  Furthermore, which format is more suitable or the best: H264 or mpeg 2/4?
    I don't know what RF means. When I have used HandBrake, I've used presets that apply to what I want to do, so I don't know the meaning of each individual setting. However, it appears that many of them are listed in the HandBrake User's Guide that is linked from the Help menu in the program:
    https://trac.handbrake.fr/wiki/HandBrakeGuide
    wongrayd wrote:
    For iMac, except iMovie, what other software is the best for the amateur?  I have read Photoshop.  Can this support m2ts files and user friendly?
    Photoshop is not amateur-level software, and although it can edit a video, it cannot burn a DVD. Unfortunately, because I still use iMovie, I haven't tried anything else. You might want to read the reviews of various DVD-burning applications in the Mac App Store.
    And maybe another forum member will jump in and help us here!

  • How can i make cotrol file which have conveyor and ?

    how can i make cotrol file which have conveyor " to move the bottle and slider " to fill the same bottle ?
    i attach my control file.............
    " Science is came....not come "
    I study Mechatronics Engineer
    skype : t_alhowaiti
    Attachments:
    convyer.ctl ‏16 KB

    Jeff·Þ·Bohrer wrote:
    billko wrote:
    ThaerAL-Hwaiti wrote:
    i want to make a production line which move a bottle on a conveyor and fill it .
    That's all good and fine, but what have you tried codewise?  Let's see what you have so far and we can go from there.
    The easy answer is "an assignment" and a desire to pass the course without actually needing to read and comprehend information.
    I as trying to be diplomatic about it. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • Ive earsed content and setting and how can i recover my files?Idont

    I have erase all content and setting in my iphone 4 s and I dont have last my files in itunes.
    How can I recover my files?

    alvin5 wrote:
    I have erase all content and setting in my iphone 4 s and I dont have last my files in itunes.
    How can I recover my files?
    Do you have an iTunes backup?
    Do you have an iCloud backup?
    If the answer to both questions is 'no', then you cannot restore the data to your device, other than maually re-entering everything.

  • How can you back up files that are on an external drive?

    How can you back up files that are on an external drive?

    hw999 wrote:
    How can you back up files that are on an external drive?
    Easy way, CLONE IT to another HD
    HD cloning software options:
    1. SuperDuper HD cloning software APP (free)
    2. Carbon Copy Cloner APP (will copy the recovery partition as well)
    3. Disk utility HD bootable clone.
    Methodology to protect your data. Backups vs. Archives. Long-term data protection
    https://discussions.apple.com/docs/DOC-6031
    hw999 wrote:But all I want to do is include the data that I store on an (second) external drive (internal drive getting too full) part of the auto back up process using timemachine.
    BAD IDEA
    You want one backup (ie Time machine) and one (or more) data archive of just all your raw files (drag and drop, or cloned etc.)

  • How can we map a file in the recepents file in smtp server

    hai all,
    how can we map a file to teh recipents file in smtp server configuration.
    because i didnt hard code the email id there so i has to kept any file or any variable so can any one help me out.
    thanks,
    Rajesh

    Hi There
    You can try to use SSIS expressions in your DTSX package which reads the values from the file and then populates the recipient field. This would require some script tasks to read the data and then populate the variables used in the SSIS expression.
    [https://www.google.com/search?sclient=psy-ab&hl=en&safe=off&site=&source=hp&q=ssisexpressions&btnK=GoogleSearch#sclient=psy-ab&hl=en&safe=off&source=hp&q=sqlssisexpressions&oq=sqlssis+expressions&aq=f&aqi=&aql=&gs_sm=e&gs_upl=9137l9524l0l9847l4l3l0l0l0l1l522l522l5-1l1l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=67c17c5b88ef2530&biw=1440&bih=799]
    It could be easier to configure a distribution list on your exchange server or domino server, and then send an email to the distribution list email address. Then you could manage the recipients from the mail server.
    Another way to achieve this, is to put a prompt in the data manager package to pass the recipient email addresses, and then pass that value to script logic. In the script logic it would call a stored procedure with the dynamic input and send the mail.
    [http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d01ce779-f1b2-2b10-07ba-da3734013245]
    You could use the SMTP relay functions from SQL server.
    There are various options available. each option has pro's and con's you will need to decide which is better and easier to manage. 
    I hope this helps.
    kind Regards
    Daniel

  • How can I transfer garageband file from iPhone to mac?

    how can i transfer garageband file from iphone to mac?

    usgorkha wrote:
    how can i transfer garageband file from iphone to mac?
    i think it's the same method as for the iPad:
    http://www.bulletsandbones.com/GB/GBFAQ.html#exportgbitogbx
    (Let the page FULLY load. The link to your answer is at the top of your screen)

Maybe you are looking for

  • Video does not work

    Under the camera-when I select the video option-the app switches to video.  I can start the video, but can not stop it by pushing the same button.  After a time period-(varies) the phone freezes up and then reboots. 

  • Error occurred during exporting ssrs report as pdf

    an error occurred during local report processing. Object reference not set to an instance of an object Thanks in advance

  • Running a page takes long time

    Hi, Running in page takes a long time in JDeveloper. I see that, every time I run a page, the tool archives/loads the following Tutalii: C:\jdevbin\jdev\appslibrt\iasjoc.zip Tutalii: C:\jdevbin\jdev\appslibrt\fwk.zip It seems that this process itself

  • What is the function module which is used to trigger email

    Hi ALL, can u send me the function module which has to trigger email when sales order was saved. kindly send me the inputs thanks & regards naveen Moderator Message: Basic Question. Thread locked. Edited by: kishan P on Nov 11, 2010 10:56 AM

  • Photosmart D5400 not printing

    Every so often, like now, when I go to print a document, I get the following infuriating error message: ""Your file could not be printed due to an error on HP Photosmart D5400 series on Ne01"" It usually happens with an Excel file, and if I copy and