[Koha] export_records.pl
Andreas Roussos
a.roussos at dataly.gr
Sun Feb 16 11:45:39 NZDT 2025
Hi Igor, All,
The actual record exporting (in export_records.pl or via the Staff
Interface) is carried out by Koha::Exporter::Record::export(), which is
in fact capable of detecting warnings reported by Perl's MARC modules,
such as an invalid record length of more than 99999 bytes when exporting
to MARC/ISO2709:
Excerpt from Koha/Exporter/Record.pm:
191 my $errorcount_on_decode = eval { scalar(
MARC::File::USMARC->decode( $record->as_usmarc )->warnings() ) };
192 if ( $errorcount_on_decode or $@ ) {
193 my $msg = "Record $record_id could not be exported.
" . ( $@ // '' );
194 chomp $msg;
195 Koha::Logger->get->info($msg);
196 next;
197 }
The 'Koha Logger' page in the Koha Community Wiki reads [1]: "By
default, only messages of warn, error or fatal will be logged in Koha.
To reveal less severe messages a Koha admin will need to modify the
Koha's Log4Perl configuration file."
That's why you don't see anything in the Koha system logs: line 195
above sets the severity to 'info' (which is lower than 'warn') and
therefore the message never gets logged.
If you modify line 195 so that it reads:
195 Koha::Logger->get->warn($msg);
you'll get something useful in your intranet-error.log, but only when
exporting via the Staff Interface.
However, thanks to Bug 14751 - Allow C4::Context->interface to be set to
'sip' or 'commandline' [2], we can define a new section in our Log4perl
configuration file so that log messages from Koha command-line utilities
will be logged appropriately.
Try adding the following lines to your
/etc/koha/sites/<instance>/log4perl.conf (replacing <instance> with your
actual Koha instance name), and then restart the koha-common service.
When you next invoke the export_records.pl script and it encounters a
warning, it will log it at /var/log/koha/<instance>/commandline-error.log.
log4perl.logger.commandline = INFO, COMMANDLINE
log4perl.appender.COMMANDLINE=Log::Log4perl::Appender::File
log4perl.appender.COMMANDLINE.filename=/var/log/koha/<instance>/commandline-error.log
log4perl.appender.COMMANDLINE.mode=append
log4perl.appender.COMMANDLINE.layout=PatternLayout
log4perl.appender.COMMANDLINE.layout.ConversionPattern=[%d] [%p] %m %l%n
log4perl.appender.COMMANDLINE.utf8=1
I hope this helps!
Kind regards,
Andreas
[1] https://wiki.koha-community.org/wiki/Koha_Logger
[2] https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14751
On 2025-02-14 12:11, Сычев Игорь Алексеевич wrote:
> Hi!
>
> How do I find these records?
>
> root at koha:~# /usr/share/koha/bin/export_records.pl --record-type=bibs --filename=koha-bibs.mrc
>
> Record length of 112264 is larger than the MARC spec allows (99999 bytes). at /usr/share/perl5/MARC/File/USMARC.pm line 314.
> Record length of 113375 is larger than the MARC spec allows (99999 bytes). at /usr/share/perl5/MARC/File/USMARC.pm line 314.
> Record length of 107982 is larger than the MARC spec allows (99999 bytes). at /usr/share/perl5/MARC/File/USMARC.pm line 314.
> Record length of 101864 is larger than the MARC spec allows (99999 bytes). at /usr/share/perl5/MARC/File/USMARC.pm line 314.
> Record length of 110662 is larger than the MARC spec allows (99999 bytes). at /usr/share/perl5/MARC/File/USMARC.pm line 314.
>
> Good Luck!
>
> Igor A. Sychev
> Tomsk Polytechnic University
> https://lib.tpu.ru/
>
>
> _______________________________________________
>
> Koha mailing list http://koha-community.org
> Koha at lists.katipo.co.nz
> Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
More information about the Koha
mailing list