dominhhai / koa-log4js Goto Github PK
View Code? Open in Web Editor NEWlog4js-node supports Koa-middleware
Home Page: https://www.npmjs.com/package/koa-log4
License: MIT License
log4js-node supports Koa-middleware
Home Page: https://www.npmjs.com/package/koa-log4
License: MIT License
Sorry to bother you again, but I have a suggestion which may solve the version issue:
If the 2.x branch is for Koa 2.x, would it make sense to add "koa": "^2.0.0"
to the package.json dependencies? (And maybe even to the 1.x branch as "koa": "^1.0.0"
for consistency?
The latest version was released 3 years ago. Are there any plans to release a new version?
Hello!
I've been trying to get this to work in a fairly basic Koa app, and though I finally succeeded I had to make a hackish workaround to do so...
According to the example app and the README.md, this should work:
app.use(log4js.koaLogger(log4js.getLogger('http'), { level: 'auto' }));
However I was getting an error:
AssertionError: app.use() requires a generator function
So I browsed the source, did some googling, did some more source browsing and some tinkering which finally amounted to this:
app.use(function *(next) {
let x = () => {return next};
yield log4js.koaLogger(log4js.getLogger('http'), { level: 'auto' })(this, x);
});
It looks like the co.wrap() returns a promise? Console.log:
{ [Function: createPromise] __generatorFunction__: [Function] }
So I tried yielding to it with next, but the logger calls yield next()
which then complains that next isn't a function. So I wrapped that too.
Am I missing something, or did this just not get updated from Koa 1.x yet? As it is, it works for me now and turns out to be less applicable than I thought to my particular project, but I figured I would open an issue to bring it to your attention anyway.
The code support custom_tokens, but if the replacement is something like ctx.request.body
,
I can't pass the option just like:
app.use(log4js.koaLogger(log4js.getLogger("http"), { level: 'auto',
tokens: [
{ token: ':body', replacement: ctx.request.body}
],
format: ':remote-addr - -' +
' ":method :url HTTP/:http-version"' +
' :status :content-length ":referrer"' +
' ":user-agent"' +
' :body'
}))
because ctx is not defined here.
I can use a wrapper, but is there any simple way to solve this problem?
when i start my project.it throw new Error :must have a property "appenders" of type object. do you know how can i slove the problem? thank you very much.
Error: Problem with log4js configuration: ({ appenders:
[ { type: 'console', category: 'http' },
{ type: 'console', category: 'kafka' },
{ type: 'console', category: 'mysql' },
{ type: 'console', category: 'redis' },
{ type: 'console', category: 'info' } ] }) - must have a property "appenders" of type object.
at tests.forEach (/media/yanqi/娱乐/work_space/comments-writer-server/node_modules/_log4js@2.5.3@log4js/lib/configuration.js:43:15)
Hi:
now the dependency log4js is 0.6
Is there any plan to update to "log4js" to "1.1.0" ?
When I use
log4js.configure(GConfig.log4jsConfig, { reloadSecs: 300 })
got warning :
WARN] log4js - Ignoring configuration reload parameter for "object" configuration.
Hi dominhhai,
After upgrading koa-log4js to 2.2.0, it could not work well as complaining:
\node_modules\.2.2.0@koa-log4\koa-logger.js:50 return async (ctx, next) => { ^ SyntaxError: Unexpected token ( at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19)
typescript version as:
$ tsc -v Version 2.2.1
while v2.1.0 works well;
May u kindly help on it, thanks~
GitHub says "We found a potential security vulnerability in one of your dependencies."
I found that the dependencies are so old, could you please update them?
$ npm ls hoek
[email protected] E:\github\HITMers\server
`-- [email protected]
`-- [email protected]
`-- [email protected]
`-- [email protected]
`-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
`-- [email protected]
`-- [email protected]
when log4js update to 2.5.1 have Error
TypeError: Cannot read property 'getLevel' of undefined
there have a Issuse
log4js-node/log4js-node#648
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.