I would like to use Log4j2 without losing its API like passing lambdas for lazy loading.
So, I would like to avoid to use Vertx LoggerFactory (returning generic Logger API) and use the Log4j2 directly.
Is there any serious drawback to consider when Log4j2 is used directly without using the Vertx logger factory?
Thank you
There's no serious drawback and it's rather the opposite: use log4j2 without going through Vert.x logging!
Vert.x logging is deprecated and will be completely internal in the future.
I tried to use log4j2 directly without using org.slf4j.Logger, however it seems that custom appenders are created twice, once by log4j2 and then once by vertx.
Related
I want to see which queries Kairosdb receives from my application and from others. How can I enable query logging?
I do not know a simple solution for that, AFAICT it is not available for configuring in kairosDB. The easier is to use a proxy.
Otherwise you may create a KairosDB plugin that adds a logger to the embedded jetty instance.
I am working on a greenfield project and I want to integrate serilog with ninject.
The use case is as follows:
There are a number of common libraries
These libraries are used in a number of modules i.e plugins. These plugins each receive a GUID at run time which is unique. This
is a base property on an abstract plugin class which every
implementation of a plugin inherits
We want to append this unique name to every log message that a plugin makes
as well as any calls to the common libraries from that plugin so that a log
message can be traced to the unique instance of a plugin that made it
We would prefer not to modify each class in the common libraries to take in a logger to use to log
My thoughts were to :
Create a singleton logger provider. This will be called by anything needing to log.
Use postsharp and CallContext.LogicalSetData to set the GUID prior to any call to the logging provider
Use CallContext.LogicalGetData to get the GUID in the singleton logger provider. This will either retrieve an existing logger for that GUID using Logger.ContextFor or create a new one to add to a dictionary.
Use Ninject to resolve the ILoggerProvider to the singleton provider always when requested
Before I down this circuitious route, is there a better way to do this, maybe with ninject?
Thanks for reading.
I went with the solution as described but due to it being a singleton there was no need for ninject in the end.
The solution is working and doesnt seem to have any performance issues logging at high volumes
System Information
Spring Cloud Data Flow Cloud Foundry: v1.1.0.RELEASE
Pivotal Cloud Foundry: v1.7.12
CF Client (Windows): cf.exe version 6.23.1+a70deb3.2017-01-13
cf-v3-plugin: 0.6.7
I would like to inject the stream name into a bean defined in my custom source module. From reviewing the /env end-point of a deployed stream I found the SPRING_CLOUD_APPLICATION_GROUP system property so I've injected this into my bean like so.
/**
* application name
*/
#Value("#{ systemProperties['SPRING_CLOUD_APPLICATION_GROUP'] }")
private String applicationName;
The issue here is that this appears to be tied to the Cloud Foundry deployer, which from my perspective is not good for portability.
In Spring XD the xd.stream.name placeholder existed for this purpose.
Is there any way to do this in a way that is portable.
Thank you
All deployer implementations should honor this variable name, so you should be good to go.
There is no strong requirement that this is passed as an environment variable though (your code assumes system property, not even sure it works, does it?). Using the Spring Environment abstraction is the best way to stay portable here.
Is it possible to use the Grails Cache plugin's annotations (ie: #Cacheable) on methods in normal Groovy classes? The plugin's documentation doesn't mention anything about normal Groovy classes and based on my own tests the annotations have no effect when used in a normal class. So I'm just wondering if there's a way to get the annotations to work in a normal Groovy class.
The current alternative is to simply directly access the cache in the method via the Cache Manager bean, but it would be nice to use the annotations instead.
No, the annotation only works on services and controllers. The plugin detects the annotation and creates a proxy for the service which intercepts all method calls and does the cache-related work first. So if there is a value in the cache for that method, it won't bother calling your real method but return the cached value instead. But if it's not cached, it will call your method and use its return value, but cache that for later.
This works because you have to retrieve the service from the Spring ApplicationContext (or have Grails do that for you) and this gives Spring a chance to give you the proxy instead of the real implementation instance, but there's no way for Spring to know about access to regular Groovy classes without AOP or some other more invasive solution.
Having said that, the plugin is probably being overly strict in limiting to only controllers and services. It handles controllers specially because those involve caching web requests instead of method return values, but there shouldn't be much difference between a Grails service and any other annotated Spring bean as far as caching goes. You can add your own Spring beans, either manually in grails-app/conf/spring/resources.groovy or by adding them to the grails.spring.bean.packages list in Config.groovy, so the plugin should be updated to look for all annotated classes. You can request this in the plugin's JIRA at https://jira.grails.org/browse/GPCACHE
I would like to use neo4j's embedded db on my web app.
Unfortunately I cannot use Spring.
Instead of instantiating a new db on each call, I'd rather inject a singleton.
How do I achieve this on Jetty ?
many thanks,
Not sure what exactly you are looking for, but I think you could inject a Neo4j instance into your servlet as a singleton via the servlets context?