Default instalation error
Closed this issue · 8 comments
I just tried the logger and when using the log4j stile mentioned in the documentation i am getting the following error:
ERROR in ./ConfigLog4j.ts
[tsl] ERROR in /home/tito/test/test/ConfigLog4j.ts(1,9)
TS2305: Module '"/home/tito/test/test/node_modules/typescript-logging/dist/commonjs/typescript-logging"' has no exported member 'LoggerFactory'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! external@1.0.0 build: `webpack ./ts/app.ts`
all i did before is installed the package using
npm install --save typescript-logging
any idea how to solve this?
many thanks
Hello,
I am not sure what you're doing - but LoggerFactory is exported (just checked a clean installation of 0.5.0).
Both log4j and category style work and log fine in a quick test, so it may be some configuration issue on your side? Perhaps toss out node_modules, and install clean and see what happens then.
If that does not work, please minimize it to a small test case with exact steps on how to reproduce this (environment, npm versions etc).
Thanks.
it is strange i do see the logger working if i compile and it seems that all is working as expected but the typescript is still complaining about the same error i.e. ERROR in ./ConfigLog4j.ts TS2305 "typescript-logging"' has no exported member 'LoggerFactory'". I will try to replicate once again on a simple project the coming week.
Odd indeed. Maybe it's some combination of versions that bite each other somehow, well if you get it reproduced let me know.
it is stage but i was able to solve this problem by changing the import statement in the ConfigLog4j.ts file to
import { LoggerFactory, LoggerFactoryOptions, LFService, LogGroupRule, LogLevel } from "./node_modules/typescript-logging/dist/commonjs/typescript-logging";
any idea why this is the case?
That works because the commonjs javascript sources are shipped along with the .d.ts in the path you mentioned. But it's not how it should normally be used.
Could you please check the following file in your project: ./node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts
That file contains the actual exports that are exposed for the library, for one you should be able to find e.g.:
export {LoggerFactory} from "./log/standard/LoggerFactory";
And the rest of them as well.
Indeed, i saw that export statement as well i.e. i do have it as well, i..e below is the whole file, however i do not understand myself why npm run build was complaining about that. Only when i specified the full path it stopped showing that error. That is the reason i opened the ticket. Unfortunately i was not able to get to the bottom of it.
import { LoggerControl } from "./control/LogGroupControl";
import { CategoryServiceControl } from "./control/CategoryServiceControl";
export * from "./extension/MessagesToExtensionJSON";
export * from "./extension/MessagesFromExtensionJSON";
export * from "./extension/ExtensionMessageJSON";
export { ExtensionHelper } from "./extension/ExtensionHelper";
export { AbstractCategoryLogger, CategoryLogMessage } from "./log/category/AbstractCategoryLogger";
export { CategoryConsoleLoggerImpl } from "./log/category/CategoryConsoleLoggerImpl";
export { CategoryDelegateLoggerImpl } from "./log/category/CategoryDelegateLoggerImpl";
export { Category } from "./log/category/Category";
export { CategoryLogger } from "./log/category/CategoryLogger";
export { CategoryRuntimeSettings } from "./log/category/CategoryRuntimeSettings";
export { CategoryConfiguration, CategoryDefaultConfiguration } from "./log/category/CategoryConfiguration";
export { RuntimeSettings } from "./log/category/RuntimeSettings";
export { CategoryMessageBufferLoggerImpl } from "./log/category/CategoryMessageBufferImpl";
export { CategoryServiceFactory } from "./log/category/CategoryServiceFactory";
export { Logger, MessageType, ErrorType } from "./log/standard/Logger";
export { LoggerFactory } from "./log/standard/LoggerFactory";
export { LoggerFactoryOptions, LFService, LogGroupRule } from "./log/standard/LoggerFactoryService";
export { AbstractLogger, LogMessage } from "./log/standard/AbstractLogger";
export { ConsoleLoggerImpl } from "./log/standard/ConsoleLoggerImpl";
export { MessageBufferLoggerImpl } from "./log/standard/MessageBufferLoggerImpl";
export { CategoryLogFormat, DateFormat, DateFormatEnum, LogFormat, LoggerType, LogLevel } from "./log/LoggerOptions";
export { CategoryServiceControl, CategoryServiceControlSettings } from "./control/CategoryServiceControl";
export { LoggerControl, LoggerFactoryControl, LogGroupControlSettings } from "./control/LogGroupControl";
export { SimpleMap, LinkedList } from "./utils/DataStructures";
export * from "./utils/JSONHelper";
export { MessageFormatUtils } from "./utils/MessageUtils";
export declare function help(): void;
export declare function getLogControl(): LoggerControl;
export declare function getCategoryControl(): CategoryServiceControl;
Hello, it looks fine by itself.
Maybe you can reduce the issue to a minimum to show the problem? So that I can run the build myself and see if it fails too. My feeling is it's related to your build setup (e.g. webpack or whatever else you are using). As right now there is not much I can do.
Closing this issue as it's very old, typescript logging 2 (major new version) has been released. Consider upgrading.