Unused log file using FileHandler for two Logger
Hi,
I'm having some troubles with the using java.util.logging classes. To demontrate my problem I prepared the following code:
package org.prove.system;
import java.util.logging.Logger;
public class Child
private static final Logger LOG = Logger.getLogger("org.prove.system");
public static void main(String[] args)
Child.LOG.info("I'm ready too!!!");
package org.prove.logging;
import java.io.IOException;
import java.util.logging.FileHandler;
public class ParentFileHandler extends FileHandler {
public ParentFileHandler() throws IOException, SecurityException {
super();
package org.prove.logging;
import java.io.IOException;
import java.util.logging.FileHandler;
public class ChildFileHandler extends FileHandler {
public ChildFileHandler() throws IOException, SecurityException {
super();
}and the following is the configuration inside my logging.properties file
# Loggers configuration
org.prove.handlers = org.prove.logging.ParentFileHandler
org.prove.level = ALL
org.prove.useParentHandlers = false
org.prove.system.handlers = org.prove.logging.ChildFileHandler
org.prove.system.level = ALL
org.prove.logging.ParentFileHandler.pattern = %h/logs/Parent.%u.log
org.prove.logging.ParentFileHandler.formatter = java.util.logging.SimpleFormatter
org.prove.logging.ParentFileHandler.append = true
org.prove.logging.ChildFileHandler.pattern = %h/logs/Child.%u.log
org.prove.logging.ChildFileHandler.formatter = java.util.logging.SimpleFormatter
org.prove.logging.ChildFileHandler.append = trueNow, if you try my example you can find, inside the "logs" directory specified in the configuration file, some files:
- Child.0.log, which is the file for the org.prove.logging.ChildFileHandler;
- Parent.0.log, which is the file for the org.prove.logging.ParentFileHandler.
but you can also find:
- Parent.1.log;
- Parent.1.log.lck.
In particular the last two files are generated by the initialization of the org.prove.logging.ParentFileHandler, because inside the method addLogger of the LogManager class, after the initialization of the demanded logger there is a cycle to identify the parent of the logger itself.
Inside that cycle is invoked again the method demandLogger that, if not already initialized, creates the Logger, and after instantiates the handlers of that logger, generating the Parent.1.log and its lock file Parent.1.log.lck. This files are not used and at the end of the execution the lock file is not deleted as the others.
I hope my problem is clear and someone can help me to identify how to resolve it.
Thanks in advance
Alessandro Cristiani
It is not possible to redirect the two different type of logs by using same log level. you have to use to different log levels for both and then in your code you have to mark specifically.
to do this you can use log levels ERROR (for exceptions) and FATAL (for errors).
First define your own logger class that will be using the log4j API's
import org.apache.log4j.Logger;
public class MyLogger {
static Logger log = Logger.getLogger(MyLogger.class);
public static logThrowable(Throwable th){
if(th instanceof Exception) {
log.error(th.getMessage());
} else {
log.fatal(th.getMessage());
}and for your log4j.xml
change the level for your ERROR_FILE to FATAL
in your LogExample
remove:
static Logger log = Logger.getLogger(LogExample.class);change:
}catch(Exception e){
log.error("Exception e");
}to
}catch(Throwable e){
MyLogger.logThrowable(e);
}Hope this helps. Or if you do not want to do in this way then you can also create your own log levels. It is not advisable but you can certainly do that.
Please visit [Log4j Manual|http://logging.apache.org/log4j/1.2/manual.html] for more on this.
Similar Messages
-
Display data in log file using PL/SQL procedure
Just as srw.message is used in Oracle RDF Reports to display data in log file in Oracle Apps, similarly how it is possible to display data in log file using PL/SQL procedure?
Please also mention the syntax too.Pl post details of OS, database and EBS versions.
You will need to invoke the seeded FND_LOG procedure - see previous discussions on this topic
Enable debug for pl/sql
https://forums.oracle.com/forums/search.jspa?threadID=&q=FND_LOG&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
HTH
Srini -
Parse log file using powershell
Hi,
Am pretty new to Powershell and would require anyone of your assistance in setting up a script which parse thru a log file and provide me output for my requirements below.
I would like to parse the Main log file for Barra Aegis application(shown below) using powershell.
Main log = C:\BARRALIN\barralin.log
Model specific log = C:\BARRALIN\log\WG*.log
Requirements :
1. scroll to the bottom of the log file and look for name called "GL Daily" and see the latest date which in the example log below is "20150203"
note : Name "GL Daily" and date keep changing in log file
2. Once entry is found i would like to have a check to see all 3 entries PREPROCESS, TRANSFER, POSTPROCESS are sucess.
3. If all 3 are success i would like to the script to identify the respective Model specific log number and print it out.
E.g if you see the sample log below for "GL Daily", it is preceded by number "1718" hence script should append the model log path with "WG00" along with 1718, finally it should look something like this C:\BARRALIN\log\WG001718.log.
4. If all 3 items or anyone of them are in "failed" state then print the same log file info with WG001718.log
Any help on this would be much appreciated.
Thank You.
Main log file :
START BARRALINK Check Auto Update 1716
43006 20150203
Trgt/Arch c:\barralin
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 43105 20150203
START Aegis GL Monthly
1716 43117 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 44435 20150203
START Aegis UB Daily
1717 43107 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 44435 20150203
START Aegis GL Daily
1718 44437 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 50309 20150203
Hi All,
I was writing a function in power shell to send email and i was looking to attach lines as and when required to the body of the email. but am not able to get this done..Here's my code
Function Email ()
$MailMessage = New-Object System.Net.Mail.MailMessage
$SMTPClient = New-Object System.Net.Mail.SmtpClient -ArgumentList "mailhost.xxx.com"
$Recipient = "[email protected]"
If ($MessageBody -ne $null)
$MessageBody = "The details of Barra $strsessionProduct model is listed below
`rHostName : $localhost
`r Model Run Date : $Date
`r Model Data Date : $DateList1
`r`n Click for full job log"+ "\\"+$localhost+"\E$\Local\Scripts\Logs "
$MailMessage.Body = $MessageBody
If ($Subject -ne $null) {
$MailMessage.Subject = $Subject
$Sender = "[email protected]"
$MailMessage.Sender = $Sender
$MailMessage.From = $Sender
$MailMessage.to.Add($Recipient)
If ($AttachmentFile -ne $null) { $MailMessage.Attachments.add($AttachmentFile)}
$SMTPClient.Send($MailMessage)
$Subject = "Hello"
$AttachmentFile = ".\barralin.log"
$MessageBody = "Add this line to Body of email along with existing"
Email -Recipient "" -Subject $Subject -MessageBody $MessageBody -AttachmentFile $AttachmentFile
as you can see before calling Email function i did add some lines to $MessageBody and was expecting that it would print the lines for $MessageBody in Email Function along with the new line. But thats not the case.
I have tried to make $MessageBody as an Array and then add contents to array
$MessageBody += "Add this line to Body of email along with existing"
$MessageBody = $MessageBody | out-string
Even this didnt work for me. Please suggest me any other means to get this done.
THank You -
How can I log BT device IDs names in a log file using Toshiba BT stack
Hi,
without Microsoft stack I can't use a lot of freeware programs (BluetoothView.exe, BluetoothCL.exe, BTScanner for Windows) to "catch" bluetooth devices in a log file.
How can I log bt device ids/description names in a log file using Toshiba Bluetooth stack?
Thank youI've just contacted Toshiba here:
http://aps2.toshiba-tro.de/bluetooth/?page=faq/sdk
There are other solutions for Windows XP or Toshiba SDK is the only one? -
Can I monitor a Log file using EMGC 10.2.0.2?
Hi,
I am thinking of monitoring my web application log file using EMGC by creating a generic service is that possible. Now we are using some shell scripts to do that but its bit difficult to maintain all these shell scripts on each of the host. Is there any in built in mechanism that enable me to monitor the log file and when a perticular pattern match I would like to send a email notification to concerned people say application admins if there is no out of box option for this do we have plugins to do this. please let me know the possibility of implementing this using EMGC or extencibility plug-ins.
Ashok Chava.Hi,
I have used "Log File Pattern Matched Line Count" of host to monitor the log files and below is the pattern I have defined for the log file. But i could not find any alerts even there are so many such exceptions in the log file matching the patteren given in EMGC.
/u01/app/oracle/product/IAS904/sysman/log/emias.log;%oracle.sysman.emSDK.util.jdk.EMException;%
I have even add the log file in agent_home/sysman/config/lfm_ifiles file as given in the documentation but I could not see any alerts as expected am I doint anything wrong in my setup.
Please let me know.
Thanks,
Ashok Chava -
Unable to remove *.log files using utl_file.fremove
Hi,
I want to remove .log files using the below command
I want to remvoe all the *.log files but its remvoing only one .log file
utl_file.fremove(location => dir_name, filename => log_file_name);
Any help will be needful for meIn the documentation for your unknown version of oracle you can view the definition of utl_file.fremove.
Everywhere it states utl_file.fremove removes a file, not 1 or more, and the documentation doesn't discuss the use of wildcards.
It seems like the question could have been prevented by reading docs (which almost no one here does), and you need to use Java to address your requirement.
Personally I wouldn't misuse Oracle to perform O/S tasks.
Sybrand Bakker
Senior Oracle DBA -
How to write to log files using java files from JSP
Anybody knows different options in writing to log files using JSP?
Do you have an example?in the init() method of the servlet put the following
FileOutputStream out = new FileOutputStream("your-log-file");
PrintStream ps = new PrintStream(out);
System.setOut(ps);
System.setErr(ps);load the servlet on startup using <load-on-startup> in web.xml -
Problem in Uploading excel file using WebDynpro for Java
Hi All
I have followed for Uploading excel file using WebDynpro for Java added by Tulasi Palnati
I done all, but I'm getting 500 Exception please contact u r system admin meag at run time also Jxl/Workbook class not found msag but i downloaded Jxl.jar file and there is no error signals in coding part. How can I solve the Problem.
Thanks
PolakaPlease ask the people in the Web Dynpro Java forum for a solution.
-
Reading/Writing .xlsx files using Webdynpro for Java
Dear All
I have a requirement to read/write excel files in .xlsx format. I am good in doing it with .xls format using jxl.jar. The jxl.jar doesn't support .xlsx format. Kindly help me in understanding how do I need to proceed on reading/writing .xlsx files using Webdynpro for Java.
Thanks and Regards
Ramamoorthy Di am using jdk 1.6.22 and IBM WebSphere
when i use poi-3.6-20091214.jar and poi-ooxml-3.6-20091214.jar to read .xlsx file. but i am getting following errors
The project was not built since its classpath is incomplete. Cannot find the class
file for java.lang.Iterable. Fix the classpath then try rebuilding this project.
This compilation unit indirectly references the missing type java.lang.Iterable
(typically some required class file is referencing a type outside the classpath)
how can i resolve it
here is the code that i have used
public class HomeAction extends DispatchAction {
public ActionForward addpage(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
String name = "C:/Documents and Settings/bharath/Desktop/Book1.xlsx";
FileInputStream fis = null;
try {
Object workbook = null;
fis = new FileInputStream(name);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);
Iterator rows = sheet.rowIterator();
int number=sheet.getLastRowNum();
System.out.println(" number of rows"+ number);
while (rows.hasNext())
XSSFRow row = ((XSSFRow) rows.next());
Iterator cells = row.cellIterator();
while(cells.hasNext())
XSSFCell cell = (XSSFCell) cells.next();
String Value=cell.getStringCellValue();
System.out.println(Value);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
return mapping.findForward("returnjsp"); -
I have a problem, my wife has an ipad with photos , emails etc etc, she has recently got herself a new iPad Air, has now been using that for two or more months, more photos (new) more emails and other stuff. What she wants to do is get all she wants from ipad 1 to new ipad without finishing up with 2 of everything which happen on previous occasion. I realise that she needs to tidy up ipad 1 first and get rid of thousands of emails etc. I need help.
Thanks kiwihdriderHi yes that works well when the new ipad hasn't been used. Trouble new one has been used for two months or more, has lots photos email etc etc. I am worried that these will go. When we did iPhone thru same process finished up with two of most things pics and emails. The emails alone were over 2 thousand and wife reluctant to delete them all. I would and just sort pics. Any other ideas
Ta -
I have been using CS6 for two years without incident. Suddenly the Media Encoder stops working, showing APPCRASH and displaying error message about WatchFolder.dll - I tried uninstalling and re-installing to no avail - can anyone help?
Hi Mylenium,
Thanks for your response.
Here is the error information showing up:
Problem signature:
Problem Event Name: APPCRASH
Application Name: Adobe Media Encoder.exe
Application Version: 6.0.0.382
Application Timestamp: 4f62fcf1
Fault Module Name: WatchFolder.dll
Fault Module Version: 6.0.0.382
Fault Module Timestamp: 4f62f37f
Exception Code: c0000005
Exception Offset: 0000000000007899
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 4105
Additional Information 1: 9a62
Additional Information 2: 9a620826d8ae4a2fa8b984b39290a503
Additional Information 3: 1fb3
Additional Information 4: 1fb304eee594288faeefbf1271b70d37
I am using a PC Windows 7 -
We have iPhone 4 and I plugged phone into after market hardwired plug in car (that we have used successfully for two years). The screen has gone black and wont turn on. Phone was charged. I have tried force quit- home screen and top button. iTunes is not recognizing phone when I plug into computer. help pls
FIRST charge with an Apple charger for at least 15 minutes. Then hold the HOME and SLEEP buttons at the same time until an Apple logo appears. Hold for up to 30 seconds. If nothing happens the phone hardware has failed.
-
Multiple log files using Log4j
Hello,
I want to generate log files based on package structure. Like com.temp.test in test.log ,also I am having a log file at application like app.log .
This is my requirement what has been logged in test.log should not be logged in app.log.This is my log4j.properties file.
# Log4j configuration file.
# Available levels are DEBUG, INFO, WARN, ERROR, FATAL
# Default logger
log4j.rootLogger=DEBUG, PFILE
log4j.logger.com.temp.test=DEBUG,TEST
# PFILE is the primary log file
log4j.appender.PFILE=org.apache.log4j.RollingFileAppender
log4j.appender.PFILE.File=./App.log
log4j.appender.PFILE.MaxFileSize=5120KB
log4j.appender.PFILE.MaxBackupIndex=10
#log4j.appender.PFILE.Threshold=DEBUG
log4j.appender.PFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.PFILE.layout.ConversionPattern=%p %d[%l][%C] %m%n
#log4j.appender.PFILE.layout.ConversionPattern=%p %d %m%n
log4j.appender.TEST=org.apache.log4j.RollingFileAppender
log4j.appender.TEST.File=./test.log
log4j.appender.TEST.MaxFileSize=5120KB
log4j.appender.TEST.MaxBackupIndex=10
log4j.appender.TEST.layout=org.apache.log4j.PatternLayout
log4j.appender.TEST.layout.ConversionPattern=%p %d[%l][%C] %m%n
Can u help me!!!You have to configure the temp logger so that it does not send its info on to the root logger.
For this, you can use the additivity flag.
# Default logger
log4j.rootLogger=DEBUG, PFILE
log4j.additivity.com.temp.test=false
log4j.logger.com.temp.test=DEBUG,TESTThe rest of the file remains the same. -
How do you generate log files using ActionScript 3?
Is there any way to log activity using AS3 by using a Red5 Media Server?
I cam across www.as3commons.org/as3-commons-logging but in this I have no clue how to access logfiles or where the logfiles are generated.
I was wondering if there's a way to generate and store log files on a media server. Say for example, I need to log when the user starts recording a video, when the connection to the media server is successful and so on.
Any help would be greatly appreciated. Thanks.In FMS backend scrips also works then log file can be create from beckend scripts.
-
Sizing the redo log files using optimal_logfile_size view.
Regards
I have a specific question regarding logfile size. I have deployed a test database and i was exploring certain aspects with regards to selecting optimal size of redo logs for performance tuning using optimal_logfile_size view from v$instance_recovery. My main goal is to reduce the redo bytes required for instance recovery. Currently i have not been able to optimize the redo log file size. Here are the steps i followed:-
In order to use the advisory from v$instance_recovery i had to set fast_start_mttr_target parameter which is by default not set so i did these steps:-
1)SQL> sho parameter fast_start_mttr_target;
NAME TYPE VALUE
fast_start_mttr_target integer 0
2) Setting the fast_start_mttr_target requires nullifying following deferred parameters :-
SQL> show parameter log_checkpoint;
NAME TYPE VALUE
log_checkpoint_interval integer 0
log_checkpoint_timeout integer 1800
log_checkpoints_to_alert boolean FALSE
SQL> select ISSES_MODIFIABLE,ISSYS_MODIFIABLE,ISINSTANCE_MODIFIABLE,ISMODIFIED from v$parameter where name like'log_checkpoint_timeout';
ISSES_MODIFIABL ISSYS_MODIFIABLE ISINSTANCE_MODI ISMODIFIED
FALSE IMMEDIATE TRUE FALSE
SQL> alter system set log_checkpoint_timeout=0 scope=both;
System altered.
SQL> show parameter log_checkpoint_timeout;
NAME TYPE VALUE
log_checkpoint_timeout integer 0
3) Now setting fast_start_mttr_target
SQL> select ISSES_MODIFIABLE,ISSYS_MODIFIABLE,ISINSTANCE_MODIFIABLE,ISMODIFIED from v$parameter where name like'fast_start_mttr_target';
ISSES_MODIFIABL ISSYS_MODIFIABLE ISINSTANCE_MODI ISMODIFIED
FALSE IMMEDIATE TRUE FALSE
Setting the fast_mttr_target to 1200 = 20 minutes of checkpoint switching according to Oracle recommendation
Querying the v$instance_recovery view
4) SQL> select ACTUAL_REDO_BLKS,TARGET_REDO_BLKS,TARGET_MTTR,ESTIMATED_MTTR, OPTIMAL_LOGFILE_SIZE,CKPT_BLOCK_WRITES from v$instance_recovery;
ACTUAL_REDO_BLKS TARGET_REDO_BLKS TARGET_MTTR ESTIMATED_MTTR OPTIMAL_LOGFILE_SIZE CKPT_BLOCK_WRITES
276 165888 *93* 59 361 16040
Here Target Mttr was 93 so i set the fast_mttr_target to 120
SQL> alter system set fast_start_mttr_target=120 scope=both;
System altered.
Now the logfile size suggested by v$instance_recovery is 290 Mb
SQL> select ACTUAL_REDO_BLKS,TARGET_REDO_BLKS,TARGET_MTTR,ESTIMATED_MTTR, OPTIMAL_LOGFILE_SIZE,CKPT_BLOCK_WRITES from v$instance_recovery;
ACTUAL_REDO_BLKS TARGET_REDO_BLKS TARGET_MTTR ESTIMATED_MTTR OPTIMAL_LOGFILE_SIZE CKPT_BLOCK_WRITES
59 165888 93 59 290 16080
After altering the logfile size to 290 as show below by v$log view :-
SQL> select GROUP#,THREAD#,SEQUENCE#,BYTES from v$log;
GROUP# THREAD# SEQUENCE# BYTES
1 1 24 304087040
2 1 0 304087040
3 1 0 304087040
4 1 0 304087040
5 ) After altering the size i have observed the anomaly as redo log blocks to be applied for recovery has increased from *59 to 696* also now v$instance_recovery view is now suggesting the logfile size of *276 mb*. Have i misunderstood something
SQL> select ACTUAL_REDO_BLKS,TARGET_REDO_BLKS,TARGET_MTTR,ESTIMATED_MTTR, OPTIMAL_LOGFILE_SIZE,CKPT_BLOCK_WRITES from v$instance_recovery;
ACTUAL_REDO_BLKS TARGET_REDO_BLKS TARGET_MTTR ESTIMATED_MTTR OPTIMAL_LOGFILE_SIZE CKPT_BLOCK_WRITES
*696* 646947 120 59 *276* 18474
Please clarify the above output i am unable to optimize the logfile size and have not been able to achieve the goal of reducing the redo log blocks to be applied for recovery, any help is appreciated in this regard.sunny_123 wrote:
Sir oracle says that fast_start_mttr target can be set to 3600 = 1hour. As suggested by following oracle document
http://docs.oracle.com/cd/B10500_01/server.920/a96533/instreco.htm
I set mine value to 1200 = 20 minutes. Later i adjusted it to 120=2 minutes as Target_mttr suggested it to be around 100 (if fast_mttr_target value is too high or too low effective value is contained in target_mttr of v$instance_recovery)Just to add, you are reading the documentation of 9.2 and a lot has changed since then. For example, in 9.2 the parameter FSMTTR was introduced and explicitly required to be set and monitored by the DBA for teh additional checkpoint writes which might get caused by it. Since 10g onwards this parameter has been made automatically maintained by Oracle. Also it's been long that 9i has been desupported followed by 10g so it's better that you start reading the latest documentation of 11g and if not that, at least of 10.2.
Aman....
Maybe you are looking for
-
I want to set up photo sharing with my Apple TV. When I go to Advanced in iTunes I find sharing options, but iTunes will not let me choose "Selected albums, events, faces" That option is gray. All I can choose is "All photos......" What am I doin
-
Photoshop Elements 11 with Windows 8 64 bits
I have seen that Photoshop Elements 11 and Premiere Elements 11 are compatible with Windows 8.1; is that correct also for Windows 8.4 64 bits or only for the 32 bits version? Thank you. MM
-
Im Using Iphone 4 with IOS 6 and when I'm trying to update it to IOS 6.0.1 from iphone(Software update tab), It says the software iOS 6.0 software is upto date.Please help
-
I bought a new iMac. iWeb and all its folders migrated over, no problem, but I cannot bring up my website - it only seems to allow for creating a new site.
-
Keep Acrobat from repeatedly warning me about not connecting to external sites thru pdfs
When I use Acrobat XI Pro to create a pdf from an original that has links to the internet (usually ad sites) the resulting pdf is blocked by Acrobat from connecting to a number of sites. That is fine, since I do not want my pdfs to connect to externa