API v1.0: custom loggers not available on Google App Engine #63
Comments
Hi @nikolash are you running into any issue or is there something you would like to see from logs? |
Hi! thank you for contacting me. The problem is, that you instantiate log4j directly instead of using the Java logging API as an abstraction layer. But:
The I would be great if you could offer a fix to this problem. Thanks! |
@nikolash thanks for sharing the exception. It is thrown while initializing logger. A fix would be to initialize it selectively, meaning that the log4j classes are instantiated if environment is not GAE. Having said that, can you share the environment variables that identifies that the env is GAE? |
I cannot confirm that, i deployed to GAE and it tries to instantiate log4j. The only setting i made was setting http.GoogleAppEngine = true. Is there anything else i have to do to tell the SDK that it runs on GAE? How can i extract the variables that you are talking about? Thanks a lot! On Tuesday, 20. January 2015 at 22:10, Juwon Lee wrote:
|
Hello Juwon, do you have any updates on this topic for me? You labeled it as Thanks! Nikolas On Tue, Jan 20, 2015 at 10:10 PM, Juwon Lee notifications@github.com
|
Hey Nikolash, We would definitely get this fixed as soon as possible. however, as you could understand it may take some more time than normal issues, as we would have to setup our GAE and test it on different machines to resolve such issue. In the mean time, if you have a specific idea/solution in mind, please feel free to send us a Pull Request, even if it is not entirely polished with everything. It would help us get started with resolving such issues faster. Thanks. |
Hi, I solved the problem by completely getting rid of the log4j dependency - replacing it instead with java.util.logging.Logger: I think there are only 6 classes in total where: private static final Logger log = LogManager.getLogger(XXX.class); has to be replaced with: private static final Logger log = Logger.getLogger(XXX.class.getName()); plus there are a few modifications to take into account the minimal syntax differences between Log4j and the Java logger. |
Thank you for doing this! I was planning the same. This is the proper way Could you please create a pull request for the SDK-API-Team, so that your Thanks! On Fri, Feb 6, 2015 at 3:11 PM, thedayofcondor notifications@github.com
|
Hi, |
Thank you! On Friday, 6. February 2015 at 18:17, Piero Filippin wrote:
|
Hello. I"m affected by the init issue as well. Is a maven central release going to be posted soon? Thanks. |
To fix the GAE logging support, we probably need a bit different approach that allows both java.util.logging as well as log4j because we already have developers using log4j for their logging. Just replacing log4j initialization with j.u.l will break their code. The tricky part is that loggers are declared as static final variables, which are loaded before configuration is set. So it may not be so straightforward to determine which logger to instantiate. We will keep this issue open for tracking, but in the mean time, we will point GAE users to @thedayofcondor 's repository for workaround. |
I never used it, but slf4j (http://slf4j.org/) offers an abstraction that allows to use different pluggable logging architectures. |
@thedayofcondor j.u.l seems to be the only supported logger in GAE. Unfortunately, slf4j is not supported either. |
I think java.util.logging is the only proper way to implement logging. Log4j can be abstracted through this layer. Existing code that uses log4j directly can be fixed easily. GAE is important and should be supported by PalPal without using unofficial forks. Thanks!
|
Hi, slf4j-api.jar it is not a logger itself, but is just a meta-logger (a wrapper around a real logger), then you have to put in your classpath the actual logger implementation you want to use and the corresponding slf4j jar, either: slf4j-jdk.jar to delegate logging to j.u.l. (eg for use with app engine) -or- slf4j-log4j.jar (and the log4j jars) to delegate logging to log4j (for anything else - this is not going to work in appengine) -or- Code modifications are really minimal: import org.slf4j.Logger;
import org.slf4j.LoggerFactory; [...] Logger logger = LoggerFactory.getLogger(Test.class);
logger.info("Hello World"); Also, slf4j jars are really minimal in size. |
So what is the currently proposed approach - will this be fixed anytime soon or will it be quicker for me to fork and remove the offending Log4J lines? |
I do have the same question..
|
I've decided to use a fork - really poor form that PayPal would leave the API requiring a 3rd party library and then mark this issue as an enhancement with no comment or position on what or how it will be resolved. |
@gslender - I am using my own fork in production until this is resolved (it is a showstopper for anyone using gae), once this is solved it will just package the updated PayPal jar. |
@juwlee, just realised that you didn't fix the issue, but rather closed the PR. If you want to continue to support your log4j user base, just use slf4j. If they include the slf4j-log4j.jar then it behaves (configuration, etc) as log4j. So it is "configuration by classpath". But please, just fix it quickly. It's a tiny change and a huge problem for users of GAE. |
Really, now I even did it for you :-) It's really just a question of merging my PR and releasing it... |
Hello!
i could not use the official Java PayPal API in the past, because unfortunately the loading of the configuration properties file failed on GAE (on v0.12.2). This has been solved in your recent release v1.0.
Unfortunately, you introduced log4j. GAE does not support custom loggers; for reference please have a look here:
https://code.google.com/p/googleappengine/issues/detail?id=11499&q=log4j&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log
Could you please provide a solution to this problem that allows us to use the API in v1.0 on GAE, thus providing a method to disable log4j support?
Thank you very much!
Nikolas
The text was updated successfully, but these errors were encountered: