to the specified file
------ Solution ------------------------------ --------------
# # # configuration error level (INFO error level , A1, R log output destination )
log4j.rootLogger = INFO, A1, R, E
# # # configure console output log information
# # # console output
log4j.appender.A1 = org.apache.log4j.ConsoleAppender
# # # output format is a custom format
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
# # # log output level
log4j.appender.A1.Threshold = ERROR
# # # log output format
log4j.appender.A1.layout.ConversionPattern =%-d {yyyy-MM-dd HH: mm: ss, SSS} [% c] - [% p]% m% n
# # # general configuration file logging information
# # # log file
log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
# # # log file output location
log4j.appender.R.File = E :/ Tomcat6.0/logs/babyfirst.log
# # # The size of each log file
log4j.appender.R.MaxFileSize = 512KB
# # # log file backups
log4j.appender.R.MaxBackupIndex = 5
# # Logging Level
log4j.appender.R.Threshold = DEBUG
# # # log output format for the custom
log4j.appender.R.layout = org.apache.log4j.PatternLayout
# # # log output format
log4j.appender.R.layout.ConversionPattern =% d {yyyy-MM-dd HH: mm: ss, SSS} [% t] [% c] [% p] ; -% m% n
# # # error log configuration
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File = E :/ Tomcat6.0/logs/babyfirstError.log
log4j.appender.E.MaxFileSize = 512KB
log4j.appender.E.MaxBackupIndex = 5
log4j.appender.E.Threshold = ERROR
log4j.appender.E.layout = org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern =% d {yyyy-MM-dd HH \: mm \: ss, SSS} [% t] [% c] [% p ] -% m% n
------ Solution ------------------------------ --------------
error level descending into : ERROR, WARN, INFO, DEBUG, when you select a priority level , enter the error message is your choice error priority and priority above error message , for example : When you are in log4j. properties file settings : log4j.rootlogger = info, xx, xx , the input of the error messages include the error, warn , and info error messages , debug error message will not be output
---- - Solution --------------------------------------------
java class : private Logger logger = Logger.getLogger (ForecastActivityDAO.class);
logger.info (" want to record under the Exception");
. properties configuration : log4j.appender.appender1.File = d :/ workspace / logs / log.txt
------ For reference only ---------------------------------- -----
log4j.appender.fileout.File = E \: \ \ tempibatis.log
------ For reference only --------- ------------------------------
log4j.properties
log4j.rootLogger = DEBUG, stdout
log4j.appender.stdout = org.apache.log4j.RollingFileAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =% d {yyyy-MM-dd HH: mm: ss}% p% c {1}.% M (% L) |% m% n
log4j.appender.stdout.MaxFileSize = 30MB
log4j.appender.stdout.MaxBackupIndex = 1
log4j.appender.stdout.file = E: \ \ output.log
You can try this configuration.
If not , I suggest google, Baidu log4j configuration
------ For reference only -------------------- -------------------
learn some of the
------ For reference only ------------------------------- --------
log.info (" got here " ) ; / / I do not want the lines in the file are also
I want ]]
have abnormal
log.error () in my build file will be reflected want is this
------ For reference only - --------------------------------------
log4j.appender.stdout.file = E : \ \ output.log
------ For reference only ----------------------------- ----------
+ +
------ For reference only -------------------------------- -------
Replies Earn 10 points every available points Oh, Oh
------ For reference only --------------- ------------------------
her brother so bad why do not people say for it
Is my language skills not
------ For reference only ----------------------- ----------------
I am not going to discuss how the output I said exception information is output to the project formulation folder
Is Nobody will log you
------ For reference only ---------------------------------- -----
hard study
------ For reference only --------------------------- ------------
simple configuration
------ For reference only ------------------------- --------------
learning , yes !
------ For reference only -------------------------------------- -
learning a
------ For reference only -------------------------------- -------
you this is what is xml configuration I said yes. properties
------ For reference only ------------------------------------- -
pre.setString (1, name);
pre.setString (1, pwd);
This will generate an exception
===================
} catch (SQLException e) {
log.error ("ss", e);
e.printStackTrace ();
} finally {
capture written so caught exception information output to a file, then no trycatch me how to capture it, then unknown exception
How to capture it, or every time I had to write catch statement to catch it
do not understand is that the old configuration on that Big Brother is xml, I am talking about . properties
=======================
------ For reference only ----------- ----------------------------
------ For reference only ---------------------------------- -----
learn about ,
------ For reference only --------------------------- ------------
log4j.properties
log4j.rootLogger = DEBUG, stdout
log4j.appender.stdout = org.apache.log4j.RollingFileAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =% d {yyyy-MM-dd HH: mm: ss}% p% c {1}.% M (% L) | ;% m% n
log4j.appender.stdout.MaxFileSize = 30MB
log4j.appender.stdout.MaxBackupIndex = 1
log4j.appender.stdout.file = E: \ \ output.log
------ For reference only ------------------ ---------------------
pre.setString (1, name);
pre.setString (1, pwd);
This will generate an exception
we look at this
===================
} catch (SQLException e) {
log.error ("ss", e);
e.printStackTrace ();
} finally {
capture written so caught exception information output to a file, then no trycatch me how to capture it, then unknown exception
How to capture it, or every time I had to write catch statement to catch it
do not understand is that the old configuration on that Big Brother is xml, I am talking about . properties
=======================
------ For reference only ----------- ----------------------------
third floor of positive solutions ! · · · ·
------ For reference only ------------------------------ ---------
I ask in a log configuration file can be simultaneously output a file info level info.log other is error. log it
in a log4j. properties in the configuration you
I also would like to catch the exception in the catch write log. error (); This place has so predictable exception trapping less , or there is no way to catch the exception catch
say something to clear a little patience
------ For reference only ---------------------------------- -----
learn it ,
------ For reference only --------------------------- ------------
------ For reference only ---------------------------------- -----
drifting , learning
------ For reference only -------------------------------- -------
trying to learn
------ For reference only ------------------------- --------------
I ask in a log configuration file can be simultaneously output a file info level info.log another is to do error.log
in a log4j. properties in the configuration you
I also would like to catch the exception in the catch write log. error (); This place has so predictable exception trapping less , or there is no way to catch the exception catch
say something to clear a little patience
------ For reference only ------------------ ---------------------
------ For reference only ---------------------------------- -----
------ For reference only ---------------------------------- -----
I ask in a log configuration file can also output a file is another info level info.log do is error.log
in a log4j. properties in the configuration you
I also would like to catch the exception in the catch write log. error (); This place has so predictable exception trapping less , or there is no way to catch the exception catch
say something to clear a little patience
------ For reference only ---------------------------------- -----
what at what time ?
------ For reference only -------------------------------------- -
is how to output an error log
------ For reference only ------------------------- --------------
not configure
------ For reference only ------------------ ---------------------
I want to ask if there should be output to the database how to configure it ?
------ For reference only -------------------------------------- -
get points leave ..
------ For reference only ---------------------------- -----------
Thank you to share ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
------ For reference only ----------- ----------------------------
------ For reference only ---------------------------------- -----
------ For reference only ---------------------------------- -----
------ For reference only ---------------------------------- -----
learned
------ For reference only ---------------------------- -----------
good
------ For reference only ---------------------- -----------------
learning ....
------ For reference only ------------ ---------------------------
Oh , learning
------ For reference only ----- ----------------------------------
I also find this method
I do not want to say but it feels like a lot of people to answer the same SB .
If I find the words I share with you and the landlord
If the landlord , then you can find out stickers
------ For reference only ------------------------ ---------------
feel to rub points are not a good look at issues like
hey . . . A little sad ah
------ For reference only ----------------------------------- ----
I have encountered this problem. . .
did not think how to solve .
http://topic.csdn.net/u / 20111011/21/757e35d2-43c3-4898-8729-8e747ec64980.html
landlord resolved not it ?
When I output error message when the front warn info are all exported.
------ For reference only -------------------------------------- -
fact, I cited the wrong package, I changed after this consequently can output a is such that when I wrote executive where what information output ; the equivalent of the output of the same system.out.println
I did not get to know when there is an error in that output when they can output error according to the error log
------ For reference only - -------------------------------------
log4j inside logger.error (); these how things are now , I use try catch the error message when put inside and then saved to the log4j logging inside . There is no need trycatch can automatically display an error message out of the way ? Is being given the program runs automatically logging.
------ For reference only ---------------------------------- -----
to configure log4j is not yet back to it, learn
没有评论:
发表评论