Hello, I am back with a problem due to a solution that I implemented with FileAppender.
I will try to resume the situation: I am trying to figure out if it is possible to create a log file dynamically just when a java process starts with the Process ID (BPM) as part of the name of the log file. I am in a project using BEA - Workshop Integration in a Windows plataform. I am talking about BPM (Business Process). There are many business process in a eai project. Those processes in my case are started (instanciated) by an insert/update/delete trigger event in an Oracle table. So the point is to create a log file to each time a process occurs. There is a process id generated for each instance of a business process. I tryed first manipulating direct the configuration xml file creating appenders and categories to filter logs of java class (the BPM class). Then I created a system property, as sugestion, to keep the ProcessId setted in run time, and to try to create the file with this property <param name="File" value="${pid}workshop.log" /> But it didnt work because the logs seems to be created at the initialization of the web server, and I couldn't change the name of the file dynamically. (I copied the discuss about this problem below) Then I implemented the creation of the file dynamically with FileAppender. It is working good, except for: ** Now comes the problem: all the log files that has been created are locked by the web server (WebLogic). We can only delete or move them when we shutdown the server... This is how I implemented. I called this method each time an instance of BPM is created. public org.apache.log4j.Logger getProcessLogger(JpdContext context, String className){ String fileName = className.substring(className.lastIndexOf(".")+1) + "_"+ context.getInstanceId(); org.apache.log4j.Logger procLog4j = org.apache.log4j.Logger.getLogger(fileName); FileAppender appender = null; String pattern = "%d{ISO8601} %-5p: %m%n"; PatternLayout layout = new PatternLayout(pattern); try { appender = new FileAppender(layout, "logDir/" + fileName + ".log"); procLog4j.addAppender(appender); procLog4j.setLevel((Level) Level.INFO); } catch(Exception e) { e.printStackTrace(); } return procLog4j; } Here is the workshop help http://e-docs.bea.com/workshop/docs81/doc/en/core/index.html Here is the complete link to the configuration file of workshop. http://e-docs.bea.com/workshop/docs81/doc/en/workshop/reference/configfiles/con_knexLogCfg_xml_ConfigurationFile.html?skipReload=true Does anyone knows why it is locked and how to solve? Thanks for help. Silvana. >>> "James Stauffer" <[EMAIL PROTECTED]> 30/03/2006 13:43 >>> My plan does depend on setting the system property before it is configured. I know that can be difficult in some environments. If two process are running in the same JVM then they would definitely have the same process id (assuming you meant a unix-type pid). To adress you real issue I would need more info about how are are running. So you have two apps in the same app server? What do you mean by process id? On 3/30/06, Silvana Lima <[EMAIL PROTECTED]> wrote: > Hi again James, > > It didnt work the setting of System property, maybe because I am not > being able to set in the correct time and place. > I am new in bea workshop integration and also in log4j api. > What happened was that when it came to the point that I set the System > propety, the log file was already created without the process Id written > on its name. > > I also would like to say something about the 2 process instances > running together. I think they are running in the same JVM, because the > aplication is deployed in the same server, dont you think? > > But thanks for the ideas, it is working now with the FileAppender > solution. > Silvana. > > >>> "James Stauffer" <[EMAIL PROTECTED]> 29/03/2006 18:19 >>> > Yes, that should work. Those two processes will use 2 different JVMs > and there shouldn't be any conflicts. > > On 3/29/06, Silvana Lima <[EMAIL PROTECTED]> wrote: > > ahh, now I got it! > > But will it work if there is more than one instance of the same > process > > running at the same time? > > I mean, two processes send out logs to the same appender and writing > on > > different lgo files? > > I will test! > > Thanks. > > > > >>> [EMAIL PROTECTED] 29/03/2006 17:44 >>> > > To do that using a config file, have your program call > > System.setProperty("pid", pid) before log4j is configured and use > the > > following in your config: > > <param name="File" value="${pid}workshop.log" /> > > > > On 3/29/06, Silvana Lima <[EMAIL PROTECTED]> wrote: > > > Sorry but I didnt understand what you meant. > > > > > > I found this tutorial > > > > > > http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html#LOG4J-Basics-Layout > > > > > > > > > > > > I am trying to implement with FileAppender > > > > > > org.apache.log4j.Logger myLog = > > > org.apache.log4j.Logger.getLogger(classeName); > > > FileAppender appender = null; > > > try { > > > appender = new FileAppender(new PatternLayout(), > ClassName > > + > > > "_"+ context.getInstanceId()); > > > } catch(Exception e) {} > > > > > > myLog.addAppender(appender); > > > myLog.setLevel((Level) Level.INFO); > > > > > > myLog.info("Test Log"); > > > > > > But thanks very much for the quick answer. > > > > > > >>> [EMAIL PROTECTED] 29/03/2006 16:06 >>> > > > If you can set the desired log name as a system property then it > > should > > > work. > > > > > > On 3/29/06, Silvana Lima <[EMAIL PROTECTED]> wrote: > > > > Hello to all, > > > > > > > > I am in a project using BEA - Workshop Integration in a Windows > > > plataform. > > > > I am trying to figure out if it is possible to create a log file > > > dynamically just when a java processe starts with the Process ID > as > > part > > > of the name of the log file. > > > > > > > > In the configuration file for Log4J it is used this > configuration > > > > > > > > <appender name="APPLOGFILE" > > > class="org.apache.log4j.RollingFileAppender"> > > > > <param name="File" value="workshop.log" /> > > > > <param name="Append" value="true" /> > > > > <param name="MaxFileSize" value="3000KB" /> > > > > <layout class="org.apache.log4j.PatternLayout"> > > > > <param name="ConversionPattern" value="%d{DATE} %-5p > > %-15c{1}: > > > %m%n"/> > > > > </layout> > > > > </appender> > > > > > > > > <category name="wlw"> > > > > <priority value="info" /> > > > > <appender-ref ref="APPLOGFILE" /> > > > > </category> > > > > > > > > ************************ > > > > I created this > > > > > > > > <appender name="MYAPPLOGFILE" > > > class="org.apache.log4j.RollingFileAppender"> > > > > <param name="File" > > > value="processes.VantiveInsertAddressSync.log" /> > > > > <param name="Append" value="true" /> > > > > <param name="MaxFileSize" value="3000KB" /> > > > > <layout class="org.apache.log4j.PatternLayout"> > > > > <param name="ConversionPattern" value="%d{DATE} %-5p > > %-15c{1}: > > > %m%n"/> > > > > </layout> > > > > </appender> > > > > > > > > <category > > > > > > name="xxx.eai.processes.vantive.manterendereco.VantiveInsertAddressSync"> > > > > <priority value="info" /> > > > > <appender-ref ref="MYAPPLOGFILE" /> > > > > </category> > > > > > > > > > > > > This works to log the VantiveInsertAddressSync process itself. > But > > > the client wants a different log for each instance of the process. > > > > Is there a way to do this with log4J API? > > > > > > > > Thanks for any help > > > > Please reply to [EMAIL PROTECTED] > > > > > > > > Silvana. -------------------------------------------------------------------------------------------------------- O conteúdo desta mensagem e de seus anexos é de uso restrito e confidencial, sendo o seu sigilo protegido por lei. Estas informações não podem ser divulgadas sem prévia autorização escrita. Se você não é o destinatário desta mensagem, ou o responsável pela sua entrega, apague-a imediatamente e avise ao remetente, respondendo a esta mensagem. Alertamos que esta mensagem transitou por rede pública de comunicação, estando, portanto, sujeita aos riscos inerentes a essa forma de comunicação. A QUALITY SOFTWARE não se responsabiliza por conclusões, opiniões, ou outras informações nesta mensagem que não tenham sido emitidas por seus integrantes. This e-mail and any attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information. In the event of any technical difficulty with this email, please contact the sender. QUALITY SOFTWARE is not responsible for conclusion, opinions or any kind of information in this message that doesnt come from our personnel. -------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]