How to set log filename dynamically

Hi all!
Could anybody give me a hint how I can set file name for log4j dynamically.
I have a log4j.properties file:
log4j.rootCategory=debug, stdout, R
#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %-6p [%c{1}] %m%n
#### Second appender writes to a file
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.File=Myfilename.log
log4j.appender.R.MaxFileSize=10000KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{ABSOLUTE} %-6p [%c{1}] %m%nand following code in my class:
Logger LOGGER = Logger.getLogger(MyClass.class);
File logFile = new File("newFilename.log");
            logFile.createNewFile();
            FileAppender r = (FileAppender)LOGGER.getAppender("R");
            r.setFile(logFile.getAbsolutePath());
            r.activateOptions();Unfortunately it does not work as r is NULL.
It throws java.lang.NullPointerException.
Could anybody help me?

I wouldn't try to mess with the file name. I'd use logging the way it is intended - with the correct log file name configured.
Even if you successfully do that, what do you suppose will happen when the log "rolls over"? Do you expect it to honor the fact that you've changed the base file name? I would expect it is going to fail when it closes the log, renames it using the rolling pattern, and creates a new log.

Similar Messages

  • How to capture the Filename Dynamically in BPM

    Hi All,
    My scenario is FileBPMFile and my target end should get the same file name as source file name.
    If suppose it is simple File to File we can use set attributes option to get the same filename.
    But if BPM comes into Middle will it be managed if so how?
    Can anyone suggest me?
    Thanks,
    Kalyan.

    Hi,
    There is no difference between File>BPM>File & File-->File with the requirement you are looking for.
    Since you are not doing any modifications to the filename read from Sender File System no need for dynamic configuration concept in UDF of any mapping.
    Do the following
    Sender File Adapter Channel.
    file name : a particular file name or a .(STAR.STAR) according to your requirement.
    e.g., test.xml (or) *.xml (or) . (STAR.STAR)
    Enable Adapter- Specific Message Attributes check box and make sure that the File Name check box is enabled. Save and Activate.
    Receiver File Adapter Channel
    file name :  . (STAR.STAR)
    Enable Adapter- Specific Message Attributes check box and make sure that the File Name check box is enabled. Save and Activate.
    Execute your scenario.
    Thanks,
    Gujjeti
    Edited by: Praveen Gujjeti on Aug 11, 2008 10:14 AM
    There is formatting problem by the portal application as some characters will have specific meaning.

  • FtpAdapter How to set the filename

    Hi,
    I am using FtpAdapter to put files I want to set the custom filename how do I do that. I am storing a filename in a variable and needs to have that name when FtpAdapter puts the file on a Ftp Server.
    Thanks

    Well to dynamically assign file name to the FTP'ed file, need to use the ftpAdapterOutboundHeader.wsdl
    Create a variable of OutboundHeader_msg message type which is defined in ftpAdapterOutboundHeader.wsdl
    Assign the custom file name to this newly created variable's fileName element.
    For example if Variable_File_Name_Obj is the variable created then the code should include
    Variable declaration
    <variable name="Variable_File_Name_Obj"
    messageType="namespace:OutboundHeader_msg"/>
    Assign
    <assign name="Assign_File_Name">
    <copy>
    <from some variable>
    <to variable="Variable_File_Name_Obj"
    part="outboundHeader"
    query="/namespace:OutboundFTPHeaderType/namespace:fileName"/>
    </copy>
    </assign>
    Kalidass
    http://oraclebpelindepth.blogspot.com/

  • How to set hostname using dynamic binding for FTP, AQ, SMTP adaptersin BPEL

    I am using Oracle BPEL and SOA 11g and my requirement is to send files and messages to different destinations ( hostname ) using dynamic JCA bindings. All hostname to be used other related information for destination is stored in database. My BPEL flow should retrieves the hostnames using one webservice and then set the hostname in FTP, AQ and SMTP adapters using dynamic JCA bindings.
    I came across http://rahullahiri.blogspot.in/2011/09/configuring-ftp-adapters-in-oracle-soa.html and http://www.soabyte.com/2010/11/jca-dynamic-partnerlinks-in-soa-11g.html but unsure if we can dynamically set the hostname also for the adapters mentioned in the BPEL flow.
    Can you please advice how it can be achieved in BPEL and what is the best way?
    Thanks for help in advance.
    Shail

    Hi,
    Its good that u pasted the complete log file. In your environment you have to run this upgrade tool only once from any of the middle tier.
    And with respect to your error that u got in precheck is quite simple. All u have to do is just run this script from by connecting to portal schema using sqlplus.
    Run dropupg.sql
    Location-------- /raid/product/OraHome_1/upgrade/temp/portal/prechktmp/dropupg.sql
    Later you re-run the upgrade tool and let me know the status.
    Good luck
    Tanmai

  • How to set logical filename..

    Hi i have to set the logical filename in the output screen in by which my report should pick the files from the specified location
    can anybody tell how should i set the logical file name...
    thanks.

    Hi,
    Check this FM,
    CALL FUNCTION 'FILE_GET_NAME'
      EXPORTING
    *   CLIENT                        = SY-MANDT
        logical_filename              =
    *   OPERATING_SYSTEM              = SY-OPSYS
    *   PARAMETER_1                   = ' '
    *   PARAMETER_2                   = ' '
    *   PARAMETER_3                   = ' '
    *   USE_PRESENTATION_SERVER       = ' '
    *   WITH_FILE_EXTENSION           = ' '
    *   USE_BUFFER                    = ' '
    *   ELEMINATE_BLANKS              = 'X'
    * IMPORTING
    *   EMERGENCY_FLAG                =
    *   FILE_FORMAT                   =
    *   FILE_NAME                     =
    * EXCEPTIONS
    *   FILE_NOT_FOUND                = 1
    *   OTHERS                        = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Vik

  • How to pass a filename dynamically in incoming email and process that file

    Hi,
    We have to process an incoming file with XI, the name of which we don't know to design time. The filename is passed dynamically in an incoming email, in the body section. We can parse the filename from the mail already. However, file adapter-sender does not accept variables (whereas receiver does), so we have no way to pass this name to the file-sender.
    What would be the best way to implement this scenario? I'd really appreciate a bit more explanation than 1-liner answers (e.g. links to help.sap.com We have SAP XI 7.0 SP15.
    TIA

    Thanks. This is similar to our plan B That is, using a wildcard, processing all files in the incoming directory, and moving them after processing. This way, only the unprocessed files would be in the source folder. IMHO, it's not elegant.
    Besides, should a second mail get received, before the first file is processed completely (e.g. due to an error, slow FTPS transfer rate, etc.), the second process would try to pick up the first file as well, which would mess up everything.
    There should be a way to set a parameter for the sender-file adapter...

  • In chart (graph), How to set scale value dynamically(user input scale val.)

    Hi ,
    I am using Crystal Reports XI R2.
    I have specified scale value but user is asking he can decide scale value while running the chart like Y-axis major interval (inclement by) 10, 7, 4, .5, .25 etc.
    How to achieve this please give me suggestions.
    Thanks and regards,
    Manjunath N. Jogin

    I do not think this can be done dynamically,   You could build several sections, each with it's own graph,
    set the scales in each graph, in its section, and then supress sections based on parameter.
    So, you could have one section that is  5,10,15,20  etc.
    and another that is 8, 12, 16, 20  
    depending on what they want.

  • How to set column heading dynamically?

    Hi:
    How can I set a column heading dynamically -by PL/SQL code- ?
    Regards,

    Hi,
    Create a formula field, and return desired heading depending on your conditions, and use that field as the column header.
    Regards,
    Manu.

  • How to set event handler dynamically?

    Hi all,
    Usually, we add event listener like this:
    myCanvas.addEventListener("click", onClick)
    How can I set the second parameter so that I can add click handler dynamically?
    For example, I have functions clickHandler1, clickHandler2, ...
    And another variable fname: String will contains value1, value2, ...
    Thanks and regards,

    You could do something like this:
    public function firstFunction():void
         trace("First Function");
    public function secondFunction():void
         trace("Second Function");
    public function callFunctionByName(name:String):void
         this[name]();
    public function addEventHandlerByName(handlerName:String):void
         this.addEventListener(Event.ENTER_FRAME, this[handlerName]);
    this.callFunctionByName("firstFunction"); //traces 'First Function'
    this.callFunctionByName("secondFunction"); //traces 'Second Function'
    Let me know if that works for you.

  • How to set target Url dynamically in submit button

    hi,
    I am using livecycle process to render a pdf form. The form has a submit button. Is it possible to set URL of submit button dynamically in a form? If yes how can i pass the target URL from process, dynamically while rendering the form? Can someone help me in this.
    Thanks,
    kripa

    Hi,
    Go to Tools > Embedded OC4J Server Preferences... > Global > Startup.
    Look for the options in "Host Name or IP Address Used to Refer to Embedded OC4J".
    William

  • How to set the filename when downloading a file?

    I'm working on mvc4. I have generated excel file dynamically using following simple code my hosting is on Azure
    I have created a Root path and then try to save that excel file.
    Problem is when my Action Result method response comes back it is giving default popup to open a file but file name is having a GUID instead my provided file name
    What id wrong any clue?
    Excel file generation code:
    Microsoft.Office.Interop.Excel.Application xlApp =
    new Microsoft.Office.Interop.Excel.Application();
    return tempPath;
    This method returns something like C:\AppData\Local\dftmp\Resources\11a2435c-998c-4fe8-aa55-8bb42455b4ca\directory\myexcelFILE.xls.
    The Download File popup does not give file name as myexcelFILE.xls it gives some GUID why so?
    Action
    Result method code
    public ActionResult DownloadExcel(){
    string path = ExcelGenerationCode(fileName);
    Stream s = new FileStream(path, FileMode.Open, FileAccess.Read);
    return new FileStreamResult(s, "application/vnd.ms-excel");
    Ashish Fugat (ashuthinksatgmail.com) SE

    http://forums.asp.net/
    The above forum has the MVC section.

  • How to set destination filename at runtime

    Hello All ,
    I want to set the destination filename at runtime , so that it will include the run date and time in the generated file name .
    It should be like this , in the distribution xml file :
    &lt;destinations&gt;
    &lt;file id="MyFiles" name="v_report_file_name" format="pdf"&gt;
    &lt;include src="report"/&gt;
    &lt;/file&gt;
    &lt;/destinations&gt;
    and v_report_file_name will be replaced by the runtime file name.
    Any ideas anybody ?
    Regards

    Hi Navneet ,
    Thanks for for your input. I tried following solution provided by you . I got the following error :
    REP-34304: Expected name instead of &lt;.
    REP-0110: Unable to open file 'C:\....\LOCALS~1\Temp\xyz_distribution00202584.xml'.
    REP-34304: Distribution failed to complete, please review the distribution lists
    I tried creating a user parameter with a default initial value and using the same parameter in the distribution file . I also tried creating a formula column in the data model and referring to it in the distribution xml file .
    The distribtion xml file contents are as under :
    &lt;destinations&gt;
    &lt;!-- Generate file for printing --&gt;
    &lt;foreach&gt;
    &lt;file id="MyFiles" name="&&lt;p_param_name&gt;.pdf" instance="this"&gt;
    &lt;include src="mainSection"/&gt;
    &lt;include src="trailerSection"/&gt;
    &lt;/file&gt;
    &lt;/foreach&gt;
    &lt;/destinations&gt;
    Did I go wrong anywhere ?
    Regards
    Shripad

  • How to set queue names dynamically for MQ Adapter - SAP XI

    Hi Friends
      I have a scenario where I should send a message to multiple queues ( more like broadcasting ) using a single communication channel of MQ Adapter. The scenario is like this
    1. If the message content contains value '111' then message should go into Queue A, Queue B, Queue C
    2. If the message content contains value '222' then message should go into Queue A, Queue B
    I will store the content values inside a table ( value and queue names ) and can pick it up inside BPM but want to know how to change the queue name property of MQ series adapter. I will do this inside a loop so the message can be sent to multiple queue names but want to know how to change the queue name property of receiver communciation channel.
    I appreciate the help in providing the answer.
    thanks
    Kannan

    Amaresh
      Thanks for your answer but my question is specifically targeted towards MQ adapter and the queue name which has to be dynamically changed. I can do the dynamic changes for file adapters but want to know how to change the queue names in message mapping or inside BPM.
    regards
    Kannan

  • How to set logging on ISE not to UTC timezone

    Hello everyone,
    I was wondering if there's a way to change the way ISE logs authentications in terms of timezone. I found that it is UTC even if I changed the timezone to my local timezone (PST8PDT).

    You are correct, the time is set before the ise application is installed. The database is primed after to configure ntp dns and basic configuration.
    Also the doc recommends using utc.
    Thanks,
    Tarik

  • Frmrwinteg: how to set cookie domain dynamically

    We are using the frmrwinteg bean for calling reports without sso with passing the userid info in an encrypted cookie. We have the following problem:
    We have to pass 'servername.domain' as the cookie domain value, e.g. 'formsserver.company.com'. Although the manual states that just passing the domain (i.e. '.company.com') is enough, we did not manage to get this working.
    Now we have a server that can be approached in two ways:
    - Directly, using the server's hostname
    - Through a reverse proxy (ibm webseal), using the proxy name.
    We have configured both servername:port combinations as virtual hosts on the http server, so both connections work, but the cookiedomain must now be set depening on which way it is called.
    The question is: can we determine within Forms (maybe using webutil?) what the original url was from where the form is started? In that case we can dynamically determine the correct value for the cookie domain.
    Or is there a way to get the cookie working with just '.company.com' as the cookie domain?

    I found some documentation why our cookie domain does not work. '.company.com' would work, but '.company.nl' (or any other country code) does NOT work. See explanation below:
    However, you CAN use it accross different hosts on the same domain, provided the domain either:
    1. ends with edu, net, gov, mil, com or org and contains at least 1 dot in it (eg you could specify xxxx.com, and use it on hosta.xxxx.com and hostb.xxxx.com) OR
    2.) ends with a country code and contains 2 dots in it (eg you could specify xxxx.com.au and use it on hosta.xxxx.com.au and hostb.xxxx.com.au).
    So it seems the servernames have to be extended with an extra level, e.g. 'hostname.servers.company.nl'.
    I do not think my customer will ever want to do that.

Maybe you are looking for