Can log4js-node run in a karma-browserify set up?

609 Views Asked by At

I am trying to learn Node test-driven frameworks.

I figured I should include a logging system, but can't seem to get it to work.

yourself@BDD0:~/BDD/simplest$ npm run test-browser

> [email protected] test-browser /home/yourself/BDD/simplest
> ./node_modules/karma/bin/karma start

INFO [framework.browserify]: registering rebuild (autoWatch=true)
INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 39.0.2171 (Linux)]: Connected on socket p0GQRPZBeIOsd2Uz1e0p with id 97681222
INFO [framework.browserify]: 103086 bytes written (2.52 seconds)
INFO [framework.browserify]: bundle built
Chrome 39.0.2171 (Linux) ERROR
    Uncaught Error: Problem reading log4js config { appenders: [ { type: 'console' } ], replaceConsole: false }. 
    Error was "Cannot find module 'console'" (Error: Cannot find module 'console'
  at s (/tmp/9e6dc093e0e34f105c98657867f51cb8bdd77edf.browserify:1:156)
          :      :
          :      :

I'm hoping someone recognizes the error and can tell me what it means.

The Chrome browser has a console. I have nodejs-console in my dependencies.

Am I trying something that log4js cannot do?

Thanx.

1

There are 1 best solutions below

0
On

Ok I got it to work.

I found it necessary to clone the log4js project and edit log4js.js, in order to add a single line :

 require('./appenders/console');

I have posted a Pull Request for my solution : Force bundling of appenders/console

I have created a little demo that shows it in action : javascript-bdd-baby-steps

Possibly my pull request will be rejected with a description of the correct solution. If so I will update here.

I hope this helps someone somewhere someday.

Update 2015/04/20:

My PR was accepted.