This project is just a parent POM for all other Java projects in "jcabi family".
See www.jcabi.com website for more details.
Static Wrapper of SLF4J easing you from the necessity to create static LOGGER instances in each Java class
Home Page: https://log.jcabi.com
License: Other
This project is just a parent POM for all other Java projects in "jcabi family".
See www.jcabi.com website for more details.
Puzzle 26-b04be6bf
in src/test/java/com/jcabi/log/ObjectDecorTest.java:66-68
has to be resolved: The ObjectDecor class is not implemented yet, that's why the test is not enabled at the moment. You should uncomment the lines below and make sure the test passes.
Puzzle 18-de8643f2
in src/test/java/com/jcabi/log/VerboseProcessTest.java:52-55
has to be resolved: Locale/encoding problem in two test methods here. I'm not sure how to fix them, but they should be fixed. They fail on some machines, while run perfectly on others. They also fail when being executed from IntelliJ.
If you have any technical questions, don't ask me, submit new tickets instead
Playing with rexsl under tomcat I've discovered an issue during container stop:
06-Jul-2014 17:00:41.928 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads The web application [] appears to have started a thread named [jcabi-loggable] but has failed to stop it. This is very likely to create a memory leak.
06-Jul-2014 17:00:41.928 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads Stack trace of thread "jcabi-loggable":
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
Puzzle 31-6c930351
in src/test/java/com/jcabi/log/ObjectDecorTest.java:66-71
has to be resolved: Let's handle arrays. For now, ObjectDecor only does a deepToString of array contents. Let's make it so that each of its members will also show its internal contents. Ensure that this is handled in a "deep" fashion; that is, if its members are also arrays, then print the contents of the members of that array member (and so on). When done, uncomment the last test case below.
If you have any technical questions, don't ask me, submit new tickets instead
Here's Maven output:
WARNUNG: Could not find class com.jcabi.log.ListDecor, due to: java.lang.Incompa
tibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMD
ASMVisitor
Jõn 25, 2015 9:31:05 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.Logger, due to: java.lang.Incompatib
leClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMDASM
Visitor
Jõn 25, 2015 9:31:06 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.MsDecor, due to: java.lang.Incompati
bleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMDAS
MVisitor
Jõn 25, 2015 9:31:06 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.MulticolorLayout, due to: java.lang.
IncompatibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visit
ors/PMDASMVisitor
Jõn 25, 2015 9:31:06 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.NanoDecor, due to: java.lang.Incompa
tibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMD
ASMVisitor
Jõn 25, 2015 9:31:07 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.ObjectDecor, due to: java.lang.Incom
patibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/P
MDASMVisitor
Jõn 25, 2015 9:31:07 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.PreFormatter, due to: java.lang.Inco
mpatibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/
PMDASMVisitor
Jõn 25, 2015 9:31:08 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.SecretDecor, due to: java.lang.Incom
patibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/P
MDASMVisitor
Jõn 25, 2015 9:31:08 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.SizeDecor, due to: java.lang.Incompa
tibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMD
ASMVisitor
Jõn 25, 2015 9:31:08 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.TextDecor, due to: java.lang.Incompa
tibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMD
ASMVisitor
Jõn 25, 2015 9:31:08 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.TypeDecor, due to: java.lang.Incompa
tibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitors/PMD
ASMVisitor
Jõn 25, 2015 9:31:09 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.VerboseProcess, due to: java.lang.In
compatibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitor
s/PMDASMVisitor
Jõn 25, 2015 9:31:10 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.VerboseRunnable, due to: java.lang.I
ncompatibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visito
rs/PMDASMVisitor
Jõn 25, 2015 9:31:10 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeRe
solver visit
WARNUNG: Could not find class com.jcabi.log.VerboseThreads, due to: java.lang.In
compatibleClassChangeError: net/sourceforge/pmd/lang/java/typeresolution/visitor
s/PMDASMVisitor
[INFO] No PMD violations found in 41 files
[INFO] \src\site\site.xml: to be validated
[INFO] jcabi-aspects 0.17.1/8b0e260 started new daemon thread jcabi-loggable for
watching of @Loggable annotated methods
[ERROR] JSR-303 validator failed to initialize: Unable to create a Configuration
, because no Bean Validation provider could be found. Add a provider like Hibern
ate Validator (RI) to your classpath. (see http://www.jcabi.com/jcabi-aspects/js
r-303.html)
[INFO] CodeNarc not required since no groovy files in d:\dev\teamed.io\jcabi-log
\src
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:03 min
[INFO] Finished at: 2015-01-25T21:31:51+04:00
[INFO] Final Memory: 26M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.qulice:qulice-maven-plugin:0.10:check (jcabi-
check) on project jcabi-log: Execution jcabi-check of goal com.qulice:qulice-mav
en-plugin:0.10:check failed: Non-zero exit code 1: -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
nException
Sometimes, very rarely, VerboseRunnable
doesn't catch the output at all and returns an empty string. For example, see http://www.rultor.com/t/723-53907230
Puzzle 38-9367cb1e
in src/main/java/com/jcabi/log/VerboseProcess.java:179-183
has to be resolved: When VerboseProcess is closed, we should also shut down the monitor threads and prevent them trying to obtain the output from the process. It should be done before destroy() is called. See the following for more details: #38 http://www.java2s.com/Code/Java/Threads/Thesafewaytostopathread.htm
If you have any technical questions, don't ask me, submit new tickets instead
Would be nice to have LoggerMocker
class, which can catch all logging messages and enable assertions on them.
Something like this:
@Test
public void testSomeCode() {
final LoggerMocker log = new LoggerMocker().mock();
// some code
log.expect(MyClass.class)
.info("works fine at this moment")
.expect(SomeOtherClass.class)
.error("some defect")
.show();
}
https://travis-ci.org/jcabi/jcabi-log/builds/27107447
Would be great to investigate and fix.
First, thanks for the awesome component!
Using for example
%d{HH:mm:ss,SSS} [%t] %color{%-5p} %color-blue{%c{1}} - %m%n
returns lines that are completely blue after debug level (incorrect, only class name should be blue)
But using:
%d{HH:mm:ss,SSS} [%t] %color{%-5p} %color-blue{%c} - %m%n
returns correctly colored lines.
Br. Jaakko
Would be convenient to have one more ctor in VerboseProcess
, with logging levels, one for stdout and one for stderr
Try this:
Logger.info(this, "Number: %d %n Text: %s", 1, "foo");
Runtime exception will be thrown.
Puzzle 143-c036470e
in src/main/java/com/jcabi/log/PreFormatter.java:46-48
has to be resolved: The class has to be annotated with @tostring, but we can't do it at the moment: https://code.google.com/p/projectlombok/issues/detail?id=457
Copyright sections still feature 2014 as a year.
I'd like to use the methods from the slf4j Logger interface that receive a throwable, like for example public void debug(String msg, Throwable t) but the static wrapper does not implement them.
Trying to decorate the Logger static wrapper won't work either because the decorator won't be able to access this method:
private static org.slf4j.Logger logger(final Object source)
which is crucial to implement the decorator.
How can I workaround this issue?
Thanks.
Everything that is not printable must be escaped.
It would be really cool to have all log4j features available, such as
https://logging.apache.org/log4j/2.x/faq.html#separate_log_files
This is really useful feature to write logs into separate files per some key.
Code below doesn't log stderr
information, I know only that process exited with error code 1.
new VerboseProcess(
new ProcessBuilder(args), Level.ALL, Level.ALL
).stdout();
@dmarkov Looks like we need to add .gitattributes to force EOL of the repo.
Right now there are four separate methods for checking if logging is enabled (e.g. isDebugEnabled
). In some cases it would be better to have a method like:
boolean enabled(Level)
so it could be called: if (enabled(Level.INFO)) {}
.
jcabi-log depends on jcabi-aspects and vice-versa.
This circular dependency can be resolved by splitting jcabi-log into jcabi-log-api and jcabi-log-impl. The dependency to jcabi-aspects is only required bz jcabi-log-impl, and jcabi-aspects can only depend on jcabi-log-api.
VerboseRunnable doesn't restore interrupted status of a thread
Puzzle 26-9f34c6f6
in src/test/java/com/jcabi/log/SecretDecorTest.java:67-69
has to be resolved: The SecretDecor class is not implemented yet, that's why the test is not enabled at the moment. You should uncomment the lines below and make sure the test passes.
When stderr-to-stderr redirection is not enabled VerboseProcess
doesn't log stderr at all
Puzzle 54-5ce25827
in src/test/java/com/jcabi/log/MulticolorLayoutTest.java:44-56
has to be resolved: Create an integration test for testing if MulticolorLayout will disable text coloring when an application is run with -Dcom.jcabi.log.coloring=false
. ... Intergration testing is required because this can't be done in a unit test: ... - We can't just pass a parameter to MulticolorLayout
that determines if the layout should color its output, because Log4J requires EnhancedPatternLayout to have a 0-arguments constructor. - We can't disable coloring with something like MulticolorLayout#setColoring(boolean)
, too, (that would be unit-testable) because Log4J won't know how to call that. - System.getProperty(String)
is not mockable for obvious reasons.... The puzzle was created by Suseika on 11-Aug-2015.
If you have any technical questions, don't ask me, submit new tickets instead
In our project site, the page http://log.jcabi.com/decors.html has a broken link. In the page template, the link to http://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html
actually links to http://log.jcabi.com/decors.html#ajava.util.Formattable
, instead of the Javadoc page.
Line 84 of src/site/apt/decors.apt.vm
currently contains:
{{{<<<java.util.Formattable>>>}http://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html}}
I think it should be:
{{{http://docs.oracle.com/javase/7/docs/api/java/util/Formattable.html}<<<java.util.Formattable>>>}}
Puzzle 26-9c2568b0
in src/test/java/com/jcabi/log/SizeDecorTest.java:66-68
has to be resolved: The SizeDecor class is not implemented yet, that's why the test is not enabled at the moment. You should uncomment the lines below and make sure the test passes.
This project could use a new Travis container-based infrastructure similar to jcabi/jcabi-github#1164
Puzzle 143-44bd09d0
in src/main/java/com/jcabi/log/DecorsManager.java:47-48
has to be resolved: The class has to be @immutable, but with ConcurrentMap it's impossible to do. Let's refactor.
mvn qulice:check -Pqulice
Line does not match expected header line of ' * BSD License'. (HeaderCheck)
messages.This is a known bug of qulice configuration in parent-0.31 (jcabi/jcabi-parent#19), accessed via jcabi-0.16. Suggested action is waiting until jcabi/jcabi#297 fix is released and upgrading jcabi version.
VerboseProcess
crashes on line 357, if underlying stream gets closed. Should be fixed. It should crash with an exception, but should correct finish the while
loop and exit.
When using e.g.:
Logger.warn(
this,
"Failed to execute FindBugs:\n%s",
command,
IOUtils.toString(process.getErrorStream())
);
The Logger
silently ignores the 4th parameter (notice the that there is only one %s
), but it should throw IllegalArgumentException
when there are more parameters then formatting string accepts.
java.lang.ClassCastException(org.aspectj.runtime.reflect.JoinPointImpl cannot be cast to com.mydomain.MyClass) out of com.mydomain.MyClass$AjcClosure19#run[1] in 366ms
Exception in thread "main"
java.lang.ClassCastException: org.aspectj.runtime.reflect.JoinPointImpl cannot be cast to com.mydomain.MyClass
at com.mydomain.MyClass$AjcClosure19.run(MyClass.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:204)
at...
Note that com.mydomain.MyClass
is extending Thread
class and has implemented run()
method. This class is annotated with @Loggable(Loggable.TRACE)
annotation. If I remove this annotation, run jcabi:ajc
and run my application, it works perfectly (though I have annotated run()
with an @Loggable(Loggable.TRACE)
annotation.
Please, publish a new release 0.17 (or higher). Don't forget to update us here regularly (at least once a week), as explained in this article.
Very often VerboseProcess
is used with following parameters:
new VerboseProcess(builder, Level.ALL, Level.ALL);
Which contrary to most people assumptions doesn't make the VerboseProcess
log all the events but makes it log none of them (Level.ALL
is lower than Level.FINEST
, and very few projects set the log level to FINEST
).
VerboseProcess
should fail if created with Level.ALL
parameters.
At the moment, the API specifies methods that look like the following:
Logger.info(Object source, String msg, Object... args)
In this case, the name of the logger will be based on the class of the source
object. I think it's better if we are able to specify the name using String. My idea is, if source
is a String instance, let's use its value as the name of the logger. Currently, specifying a String as the source
object will cause the Logger name to be java.lang.String
, which probably makes no sense to users of our API.
Let's introduce overloads that take String as the first argument, and when those versions are called, use the value of the String as the logger name.
Logger.format
doesn't look like a method that should be inside a Logger, more like an utility method.
It looks confusing when Logger.format()
is used outside logging context in other projects.
Maybe create jcabi-lang (similar to commons-lang) for such general utility methods that don't belong to other projects.
I've tried to switch thindeck project on jcabi-log 0.15 and got a lot of exceptions in test traces, like this one
[INFO] com.jcabi.ssh.SSH: $ cd /tmp/1414850462933-0;if [ -f existing-host.hosts.conf ];then if [[ $(grep '10.0.0.2:80' existing-host.hosts.conf) != *10.0.0.2:80* ]];then sed -i.bak -r 's/}/ server 10.0.0.2:80;\n}/' existing-host.hosts.conf;fi;rm existing-host.hosts.conf.bak;else printf 'upstream existing-host_servers {\n server 10.0.0.2:80;\n}' > existing-host.hosts.conf;fi;pkill -HUP -f nginx
[WARN] com.jcabi.log.VerboseRunnable: escalated exception: java.lang.IllegalStateException: java.io.IOException: Stream closed
at com.jcabi.log.VerboseRunnable$1.run(VerboseRunnable.java:139)
at com.jcabi.log.VerboseRunnable.run(VerboseRunnable.java:198)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:272)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at com.jcabi.log.VerboseProcess$Monitor.call(VerboseProcess.java:357)
at com.jcabi.log.VerboseProcess$Monitor.call(VerboseProcess.java:314)
at com.jcabi.log.VerboseRunnable$1.run(VerboseRunnable.java:133)
... 2 more
It supposed to be fixed in scope of #36 but wasn't
Issue is also a blocks others, at least this one jcabi/jcabi-mysql-maven-plugin#30
So, let's make VerboseProcess responsible for closing 2 internal monitors and then closing decorated process. IMHO, good idea if VerboseProcess would implement Closable
See my comment below #38 (comment)
This class does too much, its private functionality should be spread among multiple classes. It does formatting, parsing, coloring and managing human-readable color names, when it should only be doing formatting (as an EnhancedPatternLayout descendant). This is preventing me from fixing #53.
Review our existing source code and all other technical artifacts and report at least 8 bugs. More about such reviews you can read here. The task will be closed once we have that bugs reported and classified. Don't forget to add itr
tag to each of them.
Coloring looks really cool in terminal. Unfortunately, we also have traces.
Look at these traces http://www.rultor.com/t/2130-75708892. You can find a lot of entries, started from
[0;37mINFOm] ...
It would be grate if there will be a way to switch coloring off, for example, through system property:
-Dcom.jcabi.log.coloring=false
There is no estimate in the project yet. We have to create one as explained here
Hey!
I was wondering if there is a way to get the %L parameter in layout.ConversionPattern to work. Right now it gives me the line number of the log statement in the Logger class and it would be much better if I could get the line number in the class I called the static method.
EX: log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%color{%-5p}] %c:%L - %m%n
Thanks!
In pom.xml there is a compile time dependency to log4j. This causes dependent projects to retrieve log4j to their runtime classpath even though they might use another logger implementation.
The dependencies to log4j are caused by direct dependencies to MulticolorLayout.
The proper solution would be to make log4j an optional dependency and check at runtime if we have log4j available on the classpath (this is what commons-logging or jboss-logging do).
VerboseProcess.stdoutQuietly() logs nothing if process finishes with error
For example, I'm trying to run some java class in VerboseProcess:
java com.example.Main param1 param2
Class com.example.Main
expects 3 arguments, throws IndexOutOfBounds exception and terminates.
But I see no exceptions in logs, even if specify start process with Level.ALL
for both stdout
and stderr
Is that behaviour OK?
Let's introduce a new method VerboseProcess#stdoutQuietly()
, which will do exactly the same as stdout()
but without checking for non-zero exit code
Hello guys.
Thinking about jcabi like a monitoring project for specific functions of any application, I'm assuming, I don't want to print these logs in the same logfile who could be N size of content generate by webserver for example.
I'm able to do this one but I'm thinking what's the best way to configure the framework to printout in a specific file?
This specific file could be a default one or I'll have to pass a name for this?
The configuration should be done in the annotation or in a central configuration for all annotated methods?
What you guys think about it?
Thanks,
Mauricio Carvalho
I can't find in documentation (README.md, javadocs or log.jcabi.com) how to log exceptions (exception name + message + stacktrace).
Please add example into README.md and javadoc of Logger
on how to log exceptions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.