Comments (7)
Can you try to add the line Class.forName("com.mysql.jdbc.Driver").newInstance();
straight before configuring tinylog via the configurator class. Please exclude temporarily tinylog.properties for this test if existing.
For example:
Class.forName("com.mysql.jdbc.Driver").newInstance();
Configurator.defaultConfig()
.writer(new JdbcWriter("jdbc:mysql://10.211.55.5:3306/DATABASE", "TABLE", Arrays.asList(Value.MESSAGE)))
.activate();
Please let me know whether this works?
from tinylog.
I tried as you recommended. I got following error:
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
I skipped the Class.forName("com.mysql.jdbc.Driver").newInstance(); but the same error still occur. So I think you internally called this driver. My environment is JDBC4 and Java 1.8, mysql connector is 5.1.38. My feeling is that tinylog can’t run in this environment with jdbcwriter, right?
Also, how can i set the user and password for the connection. I tried to attach &user=XXX&password=YYY to the jdbc url.
Kind Regards
hjlabrador
Absender: Martin Winandy [email protected]
Antworten: pmwmedia/tinylog [email protected]
Datum: 29. April 2016 at 17:18:57
Empfänger: pmwmedia/tinylog [email protected]
CC: hjlabrador [email protected], Author [email protected]
Betreff: Re: [pmwmedia/tinylog] jdbcwriter didn't work (#30)
Can you try to add the line Class.forName("com.mysql.jdbc.Driver").newInstance(); straight before configuring tinylog via the configurator class. Please exclude temporarily tinylog.properties for this test if existing.
For example:
Class.forName("com.mysql.jdbc.Driver").newInstance();
Configurator.defaultConfig()
.writer(new JdbcWriter("jdbc:mysql://10.211.55.5:3306/DATABASE", "TABLE", Arrays.asList(Value.MESSAGE)))
.activate();
Please let me know whether this works?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from tinylog.
JdbcWriter just calls DriverManager.getConnection(url)
(see: JdbcWriter.java:319). This is standard Java API and should work also on your environment. Actually JdbcWriter is used quite often together with MySQL. What happens if you call DriverManager.getConnection(url)
directly?
You can pass username and password via arguments: Javadoc JdbcWriter. But ?user=X&password=Y
should work as well.
Can you share a small example project for reproducing the issue? Without example code I can just guess.
from tinylog.
So, I could get it to work with Class.forName("com.mysql.jdbc.Driver").newInstance(); ahead the Configurator as you recommended. However with tinylog.properties I still have the problem that the driver could not be found. Maybe you have an idea about your implementation. So far I can go on with my project, however the properties is a better way for configuration.
HJLabrador
Kind Regards
Absender: Martin Winandy [email protected]
Antworten: pmwmedia/tinylog [email protected]
Datum: 30. April 2016 at 11:58:02
Empfänger: pmwmedia/tinylog [email protected]
CC: hjlabrador [email protected], Author [email protected]
Betreff: Re: [pmwmedia/tinylog] jdbcwriter didn't work (#30)
JdbcWriter just calls DriverManager.getConnection(url) (see: JdbcWriter.java:319). This is standard Java API and should work also on your environment. Actually JdbcWriter is used quite often together with MySQL. What happens if you call DriverManager.getConnection(url) directly?
You can pass username and password via arguments: Javadoc JdbcWriter. But ?user=X&password=Y should work as well.
Can you share a small example project for reproducing the issue? Without example code I can just guess.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from tinylog.
I have set up a new tomcat installation from scratch. Now I'm able to reproduce the problem. Out of the box, tomcat can't load driver services. You have either to create an instance of the driver or to declare a data source. I plan to support data sources in tinylog 1.2. Help is welcome for the implementation :-)
For tinylog 1.1, I propose to load the driver via a WebListener
:
@WebListener
public class LifeCycleListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
try {
new com.mysql.jdbc.Driver();
} catch (SQLException e) {
Logger.error(e);
}
}
@Override
public void contextDestroyed(ServletContextEvent event) {
}
}
The configuration can be loaded from tinylog.properties
. You don't need to use the configurator class. It is only imported that the JDBC driver is loaded before any logger call.
from tinylog.
Fixed in tinylog 1.2 branch by supporting DataSources
from tinylog.
This closed issue has been locked automatically. However, please feel free to file a new issue.
from tinylog.
Related Issues (20)
- Error log is slower than others HOT 4
- Log to separate log files using tinyLog HOT 3
- Tinylog.org only has Javadoc for tinylog-api HOT 1
- Ability to apply specific writer HOT 1
- Structured logging HOT 2
- Ability to use SLF4J Logger's name as tag HOT 2
- Class name stripping after dollar sign $ HOT 1
- Add overloaded "isEnabled" method that takes loggerClassName instead of callerDepth HOT 1
- org.slf4j.LoggerFactory.getLogger fails with java.lang.NoClassDefFoundError: org/slf4j/spi/LoggingEventAware after upgrading to 2.6.0 HOT 3
- more verbose than necessary HOT 3
- Multiple Log Files created when rollover is initiated HOT 1
- Trying to use thread placeholder on Rolling File writer HOT 3
- tinylog not logging some messages when used via SLF4J 2.0 fluent API HOT 1
- Why Can't I find this package anywhere org.tinylog.rules HOT 1
- No clear way how to integrate with FastCSV HOT 1
- JSON Logging to the Console HOT 3
- Is there a way to tell if the logger is still active? HOT 2
- Circumvent "Error initializing logging: java.lang.UnsupportedOperationException" when using 3rd-party SDK that also uses tinylog for logging HOT 5
- Format time in UTC timezone HOT 1
- tinylog.properties does not seem to be read in version 2.6.2, but works in 2.5.0. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinylog.